Hi!
On 28 December 2012 14:42, Javier Garcia <[email protected]> wrote: > > Hi, > > I'm getting an error with a query, my question is: can i chain joins? > > My first join is to the primary table, but my second join is to the table > joined to the primary table. This is the query: > > |$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;| > > I'm getting: > > Select query cannot join with another table" Have a look at example #27 here http://www.framework.zend.com/manual/1.12/en/zend.db.table.html#zend.db.table.advanced.usage You'll need the "$select->setIntegrityCheck(false);" part. Cheers. -- List: [email protected] Info: http://framework.zend.com/archives Unsubscribe: [email protected]
