1

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 = projects.mai_id;
enter code here

1 Answer 1

1

I think here is your solution and explanation : http://www.mail-archive.com/[email protected]/msg24553.html Another solution here : Translating a query to use Zend_Db_Select

Sign up to request clarification or add additional context in comments.

3 Comments

then I get: ` SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ccgss.object' doesn't exist`
Actually I also had to change $thisfor the name of the table
While this answer may theoretically answer the question, it is better to include the essential parts of the answer here, and provide the link for reference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.