How to use Join in Zend Framework

PHP Ferrari picture PHP Ferrari · Feb 22, 2010 · Viewed 7.3k times · Source

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

Answer

David Snabel-Caunt picture David Snabel-Caunt · Feb 24, 2010

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