above suggestion does'nt work. Yii doesn't either recognize my inMonth function as a scope: Active record class "CalendarDayUser" does not have a scope named "inMonth".
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 ':end AND MONTH(CDUDate) = :month AND YEAR(CDUDate) = :year) AND (CDUStatus=0)' at line 1
'inMonth'=>array('condition'=>'DAY(CDUDate) BETWEEN 1 AND :end AND MONTH(CDUDate) = :month AND YEAR(CDUDate) = :year'),
'concept'=>array('condition'=>'CDUStatus=0'),
'published'=>array('condition'=>'CDUStatus=1'),
);
}
Executed SQL:
Executing SQL: DELETE FROM CalendarDayUser WHERE (DAY(CDUDate) BETWEEN 1 AND :end AND MONTH(CDUDate) = :month AND YEAR(CDUDate) = :year) AND (CDUStatus=0)
This scopes works well in the following query:$groepLeden = Group::model()->with(array('users.calendarDayUsers:concept:inMonth'=>array('params' => array(':end' => $aantalDagen, ':month' => $this->maand, ':year' => $this->jaar))))->findAll($criteria);
But it seems a bit strange to me that i need to have 2 scopes for the same thing. I have now a function in my model and I have a scope in scopes(), because I need that for the eagerly loading mentioned before in this topic. Is there no better/cleaner way?
If you only have scopes(), you need to supply the parameters in deleteAll() so that they can be used to bind to the parameter placeholders in the scope.