How to use Join in Zend Framework

2019-01-20 14:06发布

问题:

i am using Join query in zend.. like

$select = $table->select()
                         ->from(array('e' => 'EducationHistory'),
                                array('status_DataDictionary_id'))
                             ->join(array('r' => 'ReportOrder'),
                                    'e.id = r.EducationHistory_id',
                                    array('reportOrderStatusId' => 'r.status_DataDictionary_id'))
                        ->where('r.orderBy_Organization_id = ?', 4) 
                        ->where('r.orderBy_Person_id = ?', 1)            
                        ->group('e.enrollno');

and to do that i take help from http://framework.zend.com/manual/en/zend.db.select.html

but when i try to run that query an error occurs which say me that

Select query cannot join with another

could any one help me.? Thanks in advance.... :)

table

回答1:

Because Zend_Db_Table provides row gateway functions, which don't work if you join on other tables, you have to state that you are willing to give it up. Simply make a call to setIntegrityCheck and it will work:

$select->setIntegrityCheck(false);