Ho controllato la guida e ho fatto i sueguenti passi:
directory applicazione/cron.php
<?php
// change the following paths if necessary
$yii=dirname(__FILE__).'/../framework/yii.php';
$config=dirname(__FILE__).'/protected/config/console.php';
require_once($yii);
Yii::createConsoleApplication($config)->run();
?>
protected/config/console.php
// Any writable CConsoleApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Console Application',
// preloading 'log' component
'preload'=>array('log'),
'import'=>array(
'application.components.*',
'application.models.*',
),
// application components
'components'=>array(
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=database',
'emulatePrepare' => true,
'username' => 'root',
'password' => 'password',
'charset' => 'utf8',
'enableProfiling' => true,
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'logFile'=>'cron.log',
'levels'=>'error, warning',
),
array(
'class'=>'CFileLogRoute',
'logFile'=>'cron_trace.log',
'levels'=>'trace',
),
),
),
),
);
protected/commands/OfferteCronCommand
<?php
class OfferteCronCommand extends CConsoleCommand
{
public function run($args)
{
$offerte = Offerte::model()->findBySql('SELECT * FROM `Offerte` '.'WHERE `data_fin` = NOW()');
echo count($offerte) . " offerte found\n";
foreach ($offerte as $offerta) {
offerta->delete()
}
}
}
Ho trovato un tutorial…,mah poi per farlo richiamare dal cron…,devo installare un extension?