Yii CGridView使用关系表进行排序和搜索

Yii CGridView使用关系表进行排序和搜索,yii,Yii,我的数据库中有3个表 下面是图片,我一直在关注 以获取具有搜索和排序目的的最终网格。所以我在搜索函数中连接了两个表,如 但我为客户得到了结果,bposite搜索和排序显示了如下问题 > Error 500: <h1>CDbException</h1> > <p>CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054

我的数据库中有3个表

下面是图片,我一直在关注

以获取具有搜索和排序目的的最终网格。所以我在搜索函数中连接了两个表,如

但我为客户得到了结果,bposite搜索和排序显示了如下问题

>     Error 500: <h1>CDbException</h1>
>     <p>CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'bposite.name'
> in 'where clause'. The SQL statement executed was: SELECT
> COUNT(DISTINCT `t`.`id`) FROM `clientbposites` `t`  LEFT OUTER JOIN
> `client` `client` ON (`t`.`client_id`=`client`.`id`)  WHERE
> (bposite.name LIKE :ycp0)
> (D:\wamp\www\yi\framework\db\CDbCommand.php:516)</p><pre>#0
> D:\wamp\www\yi\framework\db\CDbCommand.php(411):
> CDbCommand->queryInternal('fetchColumn', 0, Array)

how can implement non-related table with cgridview search and sort options.

我已经一步一步地写了一篇关于这个的博客文章。如果你被卡住了,请随意阅读并提问。这里的链接不是重复我在这里写的所有内容,而是:


它似乎帮助了很多人。希望它也能帮助您:

将$criteria->together更改为true时是否有错误?没有错误,只是尝试了一下。我从下面得到了答案。嗨,非常感谢你,我从你的博客得到了答案$条件->带=数组'client','bposite';我从评论区得到的。我们需要在单个数组中添加所有关系。非常感谢你的大力帮助我还必须一起使用$critaria->来实现这一点。有关详细信息,请参阅。@MrSoundless您的页面不再可用。你能分享/更新你的博客链接吗?
>     Error 500: <h1>CDbException</h1>
>     <p>CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'bposite.name'
> in 'where clause'. The SQL statement executed was: SELECT
> COUNT(DISTINCT `t`.`id`) FROM `clientbposites` `t`  LEFT OUTER JOIN
> `client` `client` ON (`t`.`client_id`=`client`.`id`)  WHERE
> (bposite.name LIKE :ycp0)
> (D:\wamp\www\yi\framework\db\CDbCommand.php:516)</p><pre>#0
> D:\wamp\www\yi\framework\db\CDbCommand.php(411):
> CDbCommand->queryInternal('fetchColumn', 0, Array)

how can implement non-related table with cgridview search and sort options.