0
我收到一個查詢錯誤,我的問題是:我可以鏈接連接嗎?zf1:鏈接加入
我的第一次連接是到主表,但我的第二次連接是連接到主表的表。這是查詢:
$query = $this->getDbTable()->select()
->from(array('ca' => 'contracts_allotment'),
array('id',
'contracts_rooms_id' => new Zend_Db_Expr("CONCAT(room_type_desc, '-', room_characteristics_desc)")
))
->join(array('cr' => 'contracts_rooms'),
'ca.contract_rooms_id = cr.id',
array())
->join(array('rt' => 'room_types'),
'cr.room_id = rt.id',
array('room_type_desc'))
->join(array('rc' => 'room_characteristics'),
'cr.char_id = rc.id',
array('room_characteristics_desc'))
->where('contract_id = ?', $contractId);
var_dump($this->getDbTable()->fetchAll($query));die;
我越來越:
Select查詢語句不能與其他表」
錯誤來參加由Zend/Db/Table/Select::assemble()
在這裏,你有一些內部裝配():
// Check each column to ensure it only references the primary table
if ($column) {
if (!isset($from[$table]) || $from[$table]['tableName'] != $primary) {
var_dump($from[$table]['tableName'], $primary);die;
require_once 'Zend/Db/Table/Select/Exception.php';
throw new Zend_Db_Table_Select_Exception('Select query cannot join with another table');
}
}
個
的var_dump()
打印:
串(10) 「room_types」 字符串(19) 「contracts_allotment」
任何想法?
謝謝!作品! .... – ziiweb