views:

18

answers:

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
A: 

I think here is your solution and explanation : http://www.mail-archive.com/[email protected]/msg24553.html Another solution here : http://stackoverflow.com/questions/520131/translating-a-query-to-use-zend-db-select

greg0ire
then I get: ` SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ccgss.object' doesn't exist`
Rodrigo Alves
Actually I also had to change `$this`for the name of the table
Rodrigo Alves