Skip to content

Instantly share code, notes, and snippets.

@alexander-torosh
Last active December 14, 2016 05:11
Show Gist options
  • Save alexander-torosh/e1a4b8405a0109e40ab6 to your computer and use it in GitHub Desktop.
Save alexander-torosh/e1a4b8405a0109e40ab6 to your computer and use it in GitHub Desktop.
Example of using Phalcon Query Builder and Columns method
<?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();
}
}
@duythien
Copy link

duythien commented Nov 6, 2015

Nice :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment