0

我有这个工作正常的测试查询:

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();

结果:''

谢谢!

4

1 回答 1

0

我找到了,似乎它的第一个参数需要一个字符串join

$select
    ->setIntegrityCheck(false)
    ->from($role, array('name'))
    ->joinLeft('UserRole', 'Role.id = UserRole.roleId', '')
    ->where('UserRole.userId = ?', '1');
于 2012-07-16T21:15:48.743 回答