Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //$em is the entity manager
- $qb = $em->createQueryBuilder();
- // Wasteful, will select all the properties (columns) for the entity
- $qb
- ->select('Article')
- ->from('Entity\Article')
- ;
- // Better, but won't provide a structure representing our object graph (returns a flat array)
- $qb
- ->select('Article.title')
- ->from('Entity\Article')
- ;
- // Best (although fragile if trying to manipulate/persist objects later)
- $qb
- ->select('partial Article.{title}')
- ->from('Entity\Article')
- ;
- // You can select multiple properties in the partial statement
- $qb
- ->select('partial Article.{id,title,summary}')
- ->from('Entity\Article')
- ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement