Mi faccio una domanda e mi do una risposta da solo.
In caso di errore SQL con ambiguità sull’id come segue, come sistemare ?
Error 500: <h1>CDbException</h1>
<p>CDbCommand failed to execute the SQL statement: SQLSTATE[23000]:
Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous.
The SQL statement executed was:
SELECT COUNT(DISTINCT `t`.`id`)
FROM `tbl_users` `t`
LEFT OUTER JOIN `tbl_languages` `languageObj`
ON (`t`.`languageId`=`languageObj`.`id`)
WHERE ((id=:ycp0) AND (username != 'root' ))
Il problema è nel WHERE
WHERE ((id=:ycp0)
basta modificare il compare nel metodo search
$criteria->compare('t.id',$this->id);
come vedete c’è una ‘t’ che è per convenzione l’alias della prima tabella del join, come si vede anche dal SQL presente nel testo dell’errore