There are some code:
//AAA HAS_ONE BBB
AAA::model()->with(array('BBB'=>array(
'select'=>'BBB.price',
'joinType'=>'LEFT JOIN',
'params' => array(':country'=>'USA',':count'=>1),
'on'=>'BBB.country=:country AND BBB.count=:count'))
)->findByAttributes(array('anAttr'=>123));
that gives an error
PHP Error[2]: Invalid argument supplied for foreach()
in file /yii/db/ar/CActiveFinder.php at line 826
#0 /yii/db/ar/CActiveFinder.php(862): CJoinElement->populateRecord()
#1 /yii/db/ar/CActiveFinder.php(804): CJoinElement->populateRecord()
#2 /yii/db/ar/CActiveFinder.php(437): CJoinElement->runQuery()
#3 /yii/db/ar/CActiveFinder.php(68): CJoinElement->find()
#4 /yii/db/ar/CActiveRecord.php(1356): CActiveFinder->query()
#5 /yii/db/ar/CActiveRecord.php(1519): AAA->query()
#6 /home/usr/l.net/protected/commands/ServiceCommand.php(108): AAA->findByAttributes()
But the most strange is in the log. Log shows correct SQL query was executed. I see the query and can execute manually and it works. But the error does not allow me work with returned data.
I think the problem is in "LEFT JOIN".
"joinType=>INNER JOIN" gives right query and returns the data to the code, no errors.
And if I don’t use ‘on’ but use ‘condition’ instead - it also works correct!
Any ideas?