Hi,
Presume I have a database with two tables:
Campaigns and Messages
I also have all respective models and relations already tested and working.
Presume one campaign may have many messages but only one message in the campaign is ‘default’.
Now I can select particular campaign using its primary key:
$campaign = Campaigns::model()->findByPk($id);
and I can select all its messages:
$messages = $campaign->messages;
But I do not know how to select only "default" message.
I tried:
$criteria = new CDbCriteria;
$criteria->addCondition('default = 1');
$message = $messages->find($criteria);
But it only throws error:
Call to a member function find() on a non-object
Any idea how to accomplish the task?
Thanks ahead!