我有这个测试查询工作正常:
select `name` from `Role` as rl, `UserRole` as ur
WHERE rl.id = ur.roleId AND ur.userId = '1'
结果:'test'
我试图使用Zend_Table做同样的事情,但我似乎做错了。以下是我的观点:
$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();
结果:''
谢谢!
答案 0 :(得分:0)
我发现它,它似乎需要join
的第一个参数上的字符串。
$select
->setIntegrityCheck(false)
->from($role, array('name'))
->joinLeft('UserRole', 'Role.id = UserRole.roleId', '')
->where('UserRole.userId = ?', '1');