我有两个相关的表,我必须通过连接查询显示这两个表中的数据。我有这个 GridView
当我必须进行搜索时,这是“工作”的,所以这意味着如果我必须从联接表中搜索一个字段,它会工作并显示正确的结果,但我不能同时显示两个表中的所有列。
错误如下:
cdbcommand无法执行sql语句:sqlstate[42s02]:找不到基表或视图:1051未知表“pratiche”。执行的sql语句是:select pratiche.*from
pratiche t
left join clienti on id\u cliente=clienti.id limit 10
正如你所看到的 t
之后 pratiche
,因此查询失败。有什么问题吗?
public function search()
{
// @todo Please modify the following code to remove attributes that should not be searched.
$criteria=new CDbCriteria;
$criteria->select = "pratiche.*,clienti.*";
$criteria->join='LEFT JOIN clienti ON id_cliente = clienti.id';
$criteria->compare('id_pratiche',$this->id_pratiche,true);
//this is the fild that should be shown(from the joined table)
$criteria->compare('codice_fiscale',$this->codice_fiscale,true);
$criteria->select = "pratiche.*";
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
1条答案
按热度按时间tcomlyy61#
解决了的!设置标准的错误方法: