为什么我会这样:
An error occurred
Application error
Exception information:
Message: Select query cannot join with another table
在尝试加入两个表时?
我在我的模型中有这个行代码,它扩展了 Zend_Db_Table_Abstract
public function getProjects() {
$select = $this->select()
->from(array('sub' => $this))
->join(array('main' => 'main_projects'), 'main.mai_id = sub.mai_id');
return $this->fetchAll($select);
}
我在我的控制器中使用它:$this->view->entries = $this->sub_projects->getProjects();
为什么我得到这个错误?我只是想做一个简单的连接
SELECT sub.*, main.mai_title FROM sub_projects AS sub INNER JOIN main_projects AS main ON sub.mai_id = projects.mai_id;
enter code here
答案 0 :(得分:1)
我认为这是您的解决方案和解释:http://www.mail-archive.com/fw-general@lists.zend.com/msg24553.html 这里的另一个解决方案是:Translating a query to use Zend_Db_Select