Last active
December 14, 2016 05:11
-
-
Save alexander-torosh/e1a4b8405a0109e40ab6 to your computer and use it in GitHub Desktop.
Example of using Phalcon Query Builder and Columns method
This file contains hidden or 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
Nice :)