findManyToManyRowset with Zend_Db_Table_Select

Posted by Typeoneerror on Stack Overflow See other posts from Stack Overflow or by Typeoneerror
Published on 2009-09-11T03:49:30Z Indexed on 2010/06/17 0:32 UTC
Read the original article Hit count: 398

Hello. I'm trying to use a select object to filter the results of a many to many rowset. This call works great:

$articles = $this->model->findArticlesViaArticlesUsers();

This however does not:

$articles = new Default_Model_Articles();
$articleSelect = $articles->select();
$articleSelect->where("status = 'published'")
              ->order("date_published DESC")
              ->limit(1);

$articles = $this->model->findArticlesViaArticlesUsers($articleSelect);

That throws the following error:

exception 'Zend_Db_Select_Exception' with message 'You cannot define a correlation name 'i' more than once'

I can't figure out how to successfully get "articles that have the status of 'published'" using the magic many-to-many relationship (nor findManyToManyRowset). I'm at the end of my rope and thinking of just writing the sql manually. Any ideas?

© Stack Overflow or respective owner

Related posts about zend-framework

Related posts about many-to-many