Skip to content

Instantly share code, notes, and snippets.

@janmarek
Created March 28, 2011 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save janmarek/890638 to your computer and use it in GitHub Desktop.
Save janmarek/890638 to your computer and use it in GitHub Desktop.
<?php
class OfferFinder extends Blabla
{
public function whereTags(array $tags)
{
if (count($tags) === 0) {
return;
}
$ids = array_map(function ($tag) {
return $tag->getId();
}, $tags);
$res = $this->connection->executeQuery(
'select offer_id from offer_tag where tag_id in (' . implode(',', $ids) . ')'
)->fetchAll();
$offerIds = array_map(function ($row) {
return (int) $row['offer_id'];
}, $res);
$this->qb->andWhere($this->qb->expr()->in('o.id', $offerIds));
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment