yndhdq
Last Updated: February 25, 2016
·
867
· limonazzo

Select Doctrine - PHP

== Select All By Property (Column) ==

$user = $em->getRepository('Entity\User')->findByColumn('Isaac');

where
->findByColumn()

is replaced by
->findBySomeColumnLikeNameOrAge()

== Select One by Property (Column ) ==

$user = $em->getRepository('Entity\User')->findOneByColumn('limonazzo');

== Select One by (Two)Property (Column s ) ==

$array(
    'name' => 'Isaac',
    'age' => 25
);
$user = $em->getRepository('Entity\User')->findOneBy($array);

== Select DQL ==

$dql = "select u from Entity\User u";
$query = $em->createQuery($dql);
$user = $query->getResult();

== Select DQL w/parameters ==

$dql = "select u from Entity\User u where u.name = :name and u.age = :age";
$query = $em->createQuery($dql);
$query->setParameter('name','Isaac');
$query->setParameter('age','25');
$query = $em->createQuery($dql);
$user = $query->getResult();

*Sorry my bad english

Say Thanks
Respond