开发者

Error while joining tables with Zend_Db

开发者 https://www.devze.com 2023-01-17 01:46 出处:网络
Why am I getting this: An error occurred Application error Exception information: Message: Select query cannot join with another table

Why am I getting this:

An error occurred

Application error

Exception information:

Message: Select query cannot join with another table

while trying to join two tables?

I have this line code inside my model which extends 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);
}

And I use this in my controller: $this->view->entries = $this->sub_projects->getProjects();

Why the hell I get this error? I just want to make a simple join

SELECT sub.*, main.mai_title FROM sub_projects AS sub INNER JOIN main_projects AS main ON sub.mai_id 开发者_C百科= projects.mai_id;
enter code here


I think here is your solution and explanation : http://www.mail-archive.com/fw-general@lists.zend.com/msg24553.html Another solution here : Translating a query to use Zend_Db_Select

0

精彩评论

暂无评论...
验证码 换一张
取 消