I have in database two tables:
books:
- id PK
- title

authors:
- id PK
- author
- id_book FK

1 book can have many authors. I want to learn ZF so database doesn't matter
(I know it should be that also 1 author can have many books and it shouldn't
be column 'author' but column 'name' and 'surname')



I have a model:
[code]
class Model_DbTable_Books extends Zend_Db_Table_Abstract
{
        protected $_name = 'books';
        
        protected $_primary = 'id';
        
        
        public function getBooksAuthors()
        {
                $select = $this->select()
                ->from(array('b' => 'books'))
                        ->join(array('a' => 'authorsy'), 'b.id = a.id_book');
                
                return $this->fetchAll($select);
        }
}
[/code]


oraz kontroler:
[code]
class LibraryController extends Zend_Controller_Action
{
        public function indexAction()
        {
                $books = new Model_DbTable_Books();
                $this->view->list = $books->getBooksAuthors();
        }
}
[/code]


I have an error:
Select query cannot join with another table 

What is wrong with my query ?

PS. I created connection to database based on this tutorial: 
http://akrabat.com/wp-content/uploads/getting-started-with-zend-framework-163.pdf
http://akrabat.com/wp-content/uploads/getting-started-with-zend-framework-163.pdf
 
-- 
View this message in context: 
http://www.nabble.com/I-have-an-eror%3A-Select-query-cannot-join-with-another-table-tp25488217p25488217.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to