我有以下sql语句
SELECT a.* FROM accounts a
JOIN account_friends f
ON f.friend_id = a.id
WHERE f.account_id = 12;
这会导致类似
id username password email
14 test test ..
15 test2 test ..
我不能做的就是将其转换为 zend 语句。我试过这个
$accFriendTable = new Default_Model_DbTable_AccountFriends();
$query = $accFriendTable->select()->setIntegrityCheck(false);
$query->from(array('a' => 'accounts'), array('a.*'));
$query->join(array('f' => 'account_friends'), 'f.friend_id = a.id');
$query->where('f.account_id = ?', $this->_id);
$friendsList = $accFriendTable->fetchAll($query);
这导致从 accounts 表和 account_friends 表中选择这两个列,就像这样
id username password email account_id friend_id
1 test test .. 12 14
2 test2 test .. 12 15
任何帮助,将不胜感激 :)