I have User model with "type" attribute. and Product model with "title". Here is my code.
$criteria = new CDbCriteria;
$criteria->addCondition('type = "ABC"');
$criteria->mergeWith ( array (
'with' => 'products'
) );
$criteria->mergeWith ( array (
'condition' => "`products`.title LIKE '". $model->title ."'",
'together' => true
) );
$dataProvider = new CActiveDataProvider('User', array(
'criteria' => $criteria,
));
It is giving following error:-
CDbCommand failed to execute the SQL statement: SQLSTATE[23000]:
Integrity constraint violation: 1052 Column 'type' in where clause is ambiguous
My question is, how to add alias for User model so the User.type = "ABC" using above approch.