Forked from alexander-torosh/QueryBuilderQuery.php
Created
December 14, 2016 05:11
-
-
Save vietdien2005/a247034491f8cf6d31564c6ba104937a to your computer and use it in GitHub Desktop.
Example of using Phalcon Query Builder and Columns method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$qb = $this->modelsManager->createBuilder() | |
->columns(['e.*', 'i.*']) | |
->addFrom('Backend\Models\Event', 'e') | |
->innerJoin('Backend\Models\Image', 'e.id = i.event_id', 'i') | |
->where('e.id = :id:', ['id' => $some_id]); | |
$entries = $qb->getQuery()->execute(); | |
if ($entries->count()) { | |
foreach ($entries as $el) { | |
echo "title = " . $el->e->getTitle() . "<br>"; | |
echo "joined image = " . $el->i->getImageSource(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment