How to get all rows from related table using join

For programming and general questions on Zend Framework

How to get all rows from related table using join

Postby dani34 on Sat Mar 18, 2017 6:12 pm

I have two tables. First table contain offer details and second table contains offer collection of languages(collection can be selected in main offer form). I want to use query with "join" language table to get all of them in single query. How it's look like: Relation

Trying to get all of the offers I want to get all offer languages as one field.

Code: Select all
     array [
      'id' => string '11',
      'name' => string '134',
      'date' => string '01-12-2016',
      'languages' => array(all language value from related table)
     ]


Here is my query:

Code: Select all
        $select = $this->getDbTable()->select()
            ->setIntegrityCheck(false)
            ->from(array('o' => 'offers'), array('o.*'))
            ->joinLeft(array('ol' => 'offer_language'), 'ol(.)id_offer = o(.)id', array('ol.*'));

    $resultSet = $this->getDbTable()->fetchAll($select)


In that way if one offer has a three language then I get three same offer with different language field.

Zend Version: 1.11

Thanks for help.
Attachments
Untitled Diagram.png
Untitled Diagram.png (3.86 KiB) Viewed 160 times
dani34
 
Posts: 1
Joined: Sat Mar 18, 2017 6:09 pm

Return to Zend Framework

Who is online

Users browsing this forum: No registered users and 1 guest

cron