I have a problem with my CDBCriteria. Here is an example:
$criteria = new CDbCriteria;
$criteria->select = 't.f_site_id, contentcontracts.f_content_contract_id as test';
$criteria->with = 'contentcontracts';
My select works fine on the first table and the query do the job. But when i look the query sent to my database, on foreign table all fields still selected:
And if there is no clause in my select about the foreign table, it is the same. How can I do a select on my second table?
Unfortunatly, it doesn’t solve my problem… I still have all my fields in my select. Another idea?
can i see your model class file?
I need your relations() method
Here it is:
public function relations()
'contentcontracts' => array(self::HAS_MANY, 't_content_contract', 'f_site_id',
'order' => 'contentcontracts.f_subscription_date DESC'),
maybe you can use:
$result = YOURMODEL::model()
'select'=>'f_content_contract_id as test')
It works perfectly!
Just for information: CDBCriteria will always select primary key of table, so if I write:
'select'=>'f_content_contract_id as test'
Generated SQL will select field f_content_contract_id two time. Once with and once without alias.