This is my program.
<?php
/*
-
系统定时程序管理程序
-
Author:Xiangwei.Guo
-
*/
class CrontCommand extends CConsoleCommand
{
/*
* 每隔一月执行一次
* Default:每月1号0点执行
* */
public function actionEvery1Month() {
$reports =Report::model()->findAll();
}
}
And this is my config file :config/console.php
<?php
// This is the configuration for yiic console application.
// Any writable CConsoleApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Console Application',
'timeZone'=>'Asia/Shanghai',
// application components
'components'=>array(
/*'db'=>array(
'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
),*/
// uncomment the following to use a MySQL database
/*
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=testdrive',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
),
*/
'db'=>array(
'connectionString' => 'mysql:host=192.168.55.184;dbname=ldc',
'emulatePrepare' => true,
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
),
'import'=>array(
'application.models.*',
'application.components.*',
),
),
);
This is how I am running my program: yiic cront every1month
[color="#FF0000"]But I got the errors:
:\xampp\htdocs\ldc\protected>yiic cront every1month
HP Error[2]: include(Report.php): failed to open stream: No such file or direct[/color]
ry
in file D:\xampp\htdocs\ldc\lib\yii\framework\YiiBase.php at line 418
[color="#FF0000"]0 D:\xampp\htdocs\ldc\lib\yii\framework\YiiBase.php(418): autoload()
1 unknown(0): autoload()[/color]
2 D:\xampp\htdocs\ldc\protected\commands\CrontCommand.php(48): spl_autoload_cal
()
3 unknown(0): CrontCommand->actionEvery1Month()
4 D:\xampp\htdocs\ldc\lib\yii\framework\console\CConsoleCommand.php(141): Refle
tionMethod->invokeArgs()
5 D:\xampp\htdocs\ldc\lib\yii\framework\console\CConsoleCommandRunner.php(65):
rontCommand->run()
6 D:\xampp\htdocs\ldc\lib\yii\framework\console\CConsoleApplication.php(91): CC
nsoleCommandRunner->run()
7 D:\xampp\htdocs\ldc\lib\yii\framework\base\CApplication.php(162): CConsoleApp
ication->processRequest()
8 D:\xampp\htdocs\ldc\lib\yii\framework\yiic.php(33): CConsoleApplication->run(
9 D:\xampp\htdocs\ldc\protected\yiic.php(: require_once()
:\xampp\htdocs\ldc\protected>yiic cront every1month
HP Error[2]: include(Report.php): failed to open stream: No such file or direct
ry
in file D:\xampp\htdocs\ldc\lib\yii\framework\YiiBase.php at line 418
[color="#FF0000"]0 D:\xampp\htdocs\ldc\lib\yii\framework\YiiBase.php(418): autoload()
1 unknown(0): autoload()[/color]
2 D:\xampp\htdocs\ldc\protected\commands\CrontCommand.php(46): spl_autoload_cal
()
[color="#FF0000"]3 unknown(0): CrontCommand->actionEvery1Month()[/color]
4 D:\xampp\htdocs\ldc\lib\yii\framework\console\CConsoleCommand.php(141): Refle
tionMethod->invokeArgs()
5 D:\xampp\htdocs\ldc\lib\yii\framework\console\CConsoleCommandRunner.php(65):
rontCommand->run()
6 D:\xampp\htdocs\ldc\lib\yii\framework\console\CConsoleApplication.php(91): CC
nsoleCommandRunner->run()
7 D:\xampp\htdocs\ldc\lib\yii\framework\base\CApplication.php(162): CConsoleApp
ication->processRequest()
8 D:\xampp\htdocs\ldc\lib\yii\framework\yiic.php(33): CConsoleApplication->run(
9 D:\xampp\htdocs\ldc\protected\yiic.php(: require_once()
I don’t know why it happens.What should I do to fix this.