Slide 18
Slide 18 text
3 ∗ @param int $skip
4 ∗ @return Cursor
5 ∗/
6 public function findWithLimit ( $ limit = 50 , $skip = 0)
7 {
8 $qb = $this −>createQueryBuilder () ;
9 /∗∗ @var Cursor $ r e s u l t ∗/
10 $ r e s u l t = $qb−>f i e l d ( ' deleted ' )−>notEqual ( true )
11 −>skip ( $skip )
12 −>l i m i t ( $l imit )
13 −>sort ( ' twitterId ' , −1)
14 −>getQuery ()
15 −>execute () ;
16 return $result −>hydrate () ;
17 }
Listing 16: More complex nding - part 1
5.4 Find with limit, skipping, sorting and one condition
- part 2
This example is nearly the same than the previous one, beside that the
eldname is dynamic and we want this eld as 'true' or 'set' (line 11).
1 /∗∗
2 ∗ @param s t r i n g $ f i e l d
3 ∗ @param int $l imit
4 ∗ @param int $skip
5 ∗ @return Cursor
6 ∗/
7 public function findByBooleanFieldWithLimit ( $ f i e l d , $limit =
50 , $skip = 0)
8 {
9 $qb = $this −>createQueryBuilder () ;
10 /∗∗ @var Cursor $ r e s u l t ∗/
11 $ r e s u l t = $qb−>f i e l d ( $ f i e l d )−>equals ( true )
12 −>skip ( $skip )
13 −>l i m i t ( $l imit )
14 −>sort ( ' twitterId ' , −1)
15 −>getQuery ()
16 −>execute () ;
17 return $result −>hydrate () ;
18 }
Listing 17: More complex nding - part 2
February 26, 2016 18 c dknx01