I have this test query that works fine:
select `name` from `Role` as rl, `UserRole` as ur
WHERE rl.id = ur.roleId AND ur.userId = '1'
result: 'test'
I 'm trying to use Zend_Table to do the same thing but I seem to be doing it wrong. Here 's what I 'm at:
$usrRole = new Schema_UserRole(array ('db' => $db));
$role = new Schema_Role(array ('db' => $db));
$select = $role->select();
$select
->setIntegrityCheck(false)
->from(array ('rl' => $role))
->join(array ('ur' => $usrRole), 'rl.id = ur.roleId')
->where('ur.userId = ?', '1');
$rowset = $role->fetchRow($select);
$out = $rowset->toArray();
Result: ''
Thanks!
I found it, it seems it needs a string on the first parameter of join
.
$select
->setIntegrityCheck(false)
->from($role, array('name'))
->joinLeft('UserRole', 'Role.id = UserRole.roleId', '')
->where('UserRole.userId = ?', '1');