0

I cannot get primary id array, I try to debug it happens when use joinLeft function

Here my script

 //setIntegrityCheck to false to allow joins
        $roomModel = new self();

        $select = $roomModel->select(Zend_Db_Table::SELECT_WITH_FROM_PART)
                ->setIntegrityCheck(FALSE);

        //performs join aliasing table room_type to t
        $select->join(array('t' => 'room_types'), 't.room_type_id = rooms.room_type_id AND num_beds> '.$number_beds);
        ////performs join aliasing table room_status to s
        $select->join(array('s' => 'room_statuses'), 's.room_status_id = rooms.room_status_id');

        $select->joinLeft(array('chin' => 'checkin'), 'chin.checkin_date > '.$checkin.' AND chin.checkin_date <'.$checkout.'');


        $select->joinLeft(array('chout' => 'checkout'), 'chout.checkout_date >'.$checkin.' AND chout.checkout_date <'.$checkout.'');


        $result = $roomModel->fetchAll($select);

What causes it to happen?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Akram
  • 423
  • 2
  • 5
  • 13

1 Answers1

0

one of the tables you are joining also may contain a column named like your primary key and if the row does not exist it will override it with null.

you should choose which columns you want from each table:

$select->join('table', 'condition', array('column1', 'column2', 'column3'));
$select->joinLeft('table', 'condition', array('column1', 'column2', 'column3'));
Mircea Soaica
  • 2,829
  • 1
  • 14
  • 25