Reputation: 11
I have created a croncommand and used sql statement in a function but when i am running it by using command php protected/yiic cron
,it throws error:
exception 'CException' with message 'CConsoleApplication and its behaviors do not have a method or closure named "createCommand".' in /home/sbl13/public_html/atp/yii/framework/base/CComponent.php:266
My function is
public function actionSendFeedbackReminder()
{
$sql = "SELECT training.id,session.trainingid,
group_concat(session.id),min(c_startdate) AS start,
max(c_enddate) AS end,training.programid,catalog.title
FROM training JOIN session ON
session.trainingid=training.id
JOIN catalog ON catalog.id=training.catalogueid
WHERE training.active=1 and session.active=1
GROUP BY trainingid"; // query to get data from databse
$data = Yii::app()->createCommand($sql)->queryAll(); //throws error here
}
I am not getting any help from google
Upvotes: 0
Views: 228
Reputation: 14860
createCommand
is a function of CDbConnection
and not of CConsoleApplication
. Your code should read:
$data = Yii::app()->db->createCommand($sql)->queryAll();
Upvotes: 1