criteria ambiguous error

If "with" is used by "criteria", pk of relation will have been automatically added to the "order by" phrase. And it has caused the ambiguous error.

How can it avoid inserting "id"?

I would like to search table"log_matter" by using "$matterid" as a key,

and to acquire data order by "dtUpd". And I would like to acquire "strName" from Chargers.

Specifically, they are the following contents.

[tables]

log_matter

[indent] id (pk)

iMatterid

dtUpd

strUpdated

iChargerId[/indent]

Chargers

[indent] id (pk)

strName[/indent]

[model:Logmatter.php]

[error message]

I am looking forward to your reply.

It is weird. Never happened with me before although I used similar things numerous times in the past. The only difference in my code is I used to set $criteria->together = true as well.

Thanks Greg.

Although I added this, the same error occurred.

I gave up using relation and used "left outer join".




$criteria->select='dtUpd,strUpdated,charger.strName';

$criteria->join='LEFT OUTER JOIN `chargers` `charger` ON (`t`.`iChargerId`=`charger`.`id`)' ;

$criteria->condition='iMatterid=:iMatterid';

$criteria->params=array(':iMatterid'=>$matterid);

$criteria->order='t.dtUpd';



However, I am very unwilling.

Aren’t there those who know the cause?

Unfortunately the yii community is not too big and the ones who knows the framework inside-out I assume are working on the code. So help is not coming everytime but if you dig in the code you can figure out why it is happening for you.

Try out with adding below to order


$criteria->order='t.id';

I too experienced same error when having same column name in both tables.Then we have to specify which table.

This time, I could not but give up on account of time. However, I wish to be helpful to other users. I will investigate from now on as perfectly as possible.

thanks Aruna.

I had already tried this. ‘id’ has still been added. It may be necessary to investigate this problem deeply so that Greg may say.