user1083320
user1083320

Reputation: 1946

using join() in Zend Model

I would like to create a model using join. This is the code i have:

$userModel = new self;
$select = $userModel->select();
$select->setIntegrityCheck(false)
   ->from(array('u' => 'accounts'),array('username','email'))
   ->where('u.id = ?',$id)
   ->join(array('i' => 'permissions'),'i.user_id = u.id',array('permission_type'));
$user = $userModel->fetchRow($select);

This works perfectly. The only problem is that the permission_type in permissions table has multiple entries. Using this code, I only get the first entry in the model! Is there a way to get around that, and get all the entries?

Upvotes: 3

Views: 126

Answers (1)

Erik
Erik

Reputation: 2264

I believe you might be looking for fetchAll. Like this:

...
$users = $userModel->fetchAll($select);

More information here http://framework.zend.com/manual/1.12/en/zend.db.table.rowset.html

Upvotes: 5

Related Questions