Hi, i use 2 tables for search.
table 1: id, name, date, tag, title
table 2: id, post_id, item_name
My controller:
$this->_criteria = new CDbCriteria();
$this->_criteria2 = new CDbCriteria();
$this->_criteria->select = array('id, name, tag ');
/....same code.../
$this->_criteria->distinct=true;
$this->_criteria->mergeWith(array(
'with' => array(
'table2' => array(
'select' => false,
'joinType' => 'INNER JOIN',
),
),
));
$this->_criteria->mergeWith($this->_criteria2);
/**rendering**/
If i use the select drop this error:
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in field list is ambiguous. The SQL statement executed was: SELECT DISTINCT id,
But, when i dont use, dont drop error and show items.
Solved:
$this->_criteria->select = array('t.id, name, tag ');