CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1065 Query was empty. The SQL statement executed was:
$sql = "SELECT count(a.id_alert) AS alert_counter,a.date_created,a.id_company,c.company
FROM alert a JOIN alert_kid ak ON a.id_alert=ak.id_alert JOIN kid k ON ak.id_kid=k.id_kid JOIN company c ON c.id_company=a.id_company JOIN customer cs ON cs.id_customer=a.id_customer
WHERE true ".$addtoquery."
GROUP BY date(a.date_created) LIMIT 10 OFFSET ".$page;
print_r($sql); exit;
$command=Yii::app()->db->createCommand($sql);
$resultSet=$command->queryAll();
when i write this query in mysql directly then its give me proper result.but here its give me error mention above
$command=Yii::app()->db->createCommand($sql);
$resultSet=$command->queryAll();
please help me thanx a lot