Created
January 17, 2014 03:11
-
-
Save johnnypeck/8467782 to your computer and use it in GitHub Desktop.
If I use the randProps variable as the identifiers Doctrine ORM somehow still returns records where the managedStatus is not 20.
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
if ($comparison->getIds()) { | |
$identifiers = $comparison->getIds(); | |
$random = false; | |
} else { | |
// we go random | |
$random = true; | |
/* @var $conn \Doctrine\DBAL\Connection */ | |
$conn = $this->get('database_connection'); | |
$stmt = $conn->executeQuery('SELECT id, managedStatus FROM property p WHERE managedStatus = ?', array(20)); | |
$props = $stmt->fetchAll(); | |
$randProps = array_rand($props, 3); | |
$identifiers = $randProps; | |
} | |
$hydrationMode = Query::HYDRATE_OBJECT; | |
$em = $this->getDoctrine()->getManager(); | |
$repo = $em->getRepository('Attache\MainBundle\Entity\Property'); | |
/* @var $qb \Doctrine\ORM\QueryBuilder */ | |
$qb = $repo->createQueryBuilder('p'); | |
$qb | |
->where($qb->expr()->in('p.id', ':values')) | |
->setParameter('values', $identifiers) | |
; | |
$properties = $qb->getQuery()->setHydrationMode($hydrationMode)->execute(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I dump the identifiers returned by the DBAL there are no records without a managedStatus of 20. Once it gets to the last query it ends up returning records that have a managedStatus of 20. Why? I'm missing something for sure.