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
Written by Isaac Limon G.
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#