Revision #2                                    has been created by  Roman Solomatin                                    on May 27, 2013, 10:34:33 AM with the memo:
 Roman Solomatin                                    on May 27, 2013, 10:34:33 AM with the memo:
                                
                                
                                    Updated markdown syntax.                                
                                                                    « previous (#1)                                                                                                    next (#3) »                                                            
                            Changes
                            
    Title
    unchanged
    Cron Jobs in Yii
    Category
    unchanged
    How-tos
    Yii version
    unchanged
    
    Tags
    unchanged
    cron, cronjobs, heroku, bash, console, Yii Console, yiic
    Content
    changed
    [...]
'parameters' => 'text',
	'execution_result' => 'text'
));
```
Next, I generated a model using Gii. Then I added two methods. 
 
 
 
~~~
 
	:
 
 
```php 
public function beforeValidate(){
		if(gettype($this->parameters) !== "string"){
			$this->parameters = serialize($this->parameters);[...]
return parent::afterFind();
	}
~~~```
When you are creating a new CronJob, pass any parameters in as an array and the Model will serialize them for you.[...]
Next, we need the CronCommand so that we can process these jobs from the command line. I set mine up with one action (actionIndex) that processes all the jobs. It selects all the jobs that need to be executed that haven't yet been, and starts to process them. 
For all the code, check out the github page at [https://github.com/aarondfrancis/yii-CronCommand](https://github.com/aarondfrancis/yii-CronCommand "https://github.com/aarondfrancis/yii-CronCommand"). There you will find the migration, the model, the console command, and a bash script for if you are on Heroku.