Hi everybody,
I am new to Yii and so to the Forum. But I need your help to understand a really esoteric behaviour…
We have a Database with a field ‘status’. Status is an int and can be from 0 to 10. I created some scopes to get the data I want:
public function scopes()
{
return array(
'latestProjects' => array(
'order' => 'date DESC',
'condition' => "status = '5'"
),
'groupInternal' => array(
'group' => 'internalProjectID'
)
);
}
(of course, the status condition will be a parameterized scope, but it doesn’t matter for the tests…)
Then I call
$proposalData = new CActiveDataProvider(Project::model()->latestProjects()->groupInternal(), array());
It works fine when status is > 5 (6, 7, etc.), but any status beyond 5 gets me a
CDbException
CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') GROUP BY internalProjectID) sq' at line 1. The SQL statement executed was: SELECT COUNT(*) FROM (SELECT * FROM `tw_project` `t` WHERE (status = '5') AND () GROUP BY internalProjectID) sq
Exception… and we don’t know why. The query can’t be wrong, because with status = 6 (or status < 6 oder status <= 6) it works fine…
Can anybody help?
Thanks in advance!