How to achieve this query in phalcon using query builder (best method):
$results = " select * from table where name like 'A%' limit 10 "; // <-- 10 records
$total = " select count(1) from table where name like 'A%' "; // <-- 100 records
return [
'data' => $result,
'total' => $total
];
im extjs user and i need to get total over limit to display paging information (eq: displaying 1 to 10 from 100 records)
thx.
are these methods valid?
$builder = new Builder();
$results = $builder
->from(__CLASS__)
->where('name like :name:', array('name'=>'A%'))
->andWhere(...)
->andWhere(...)
->orderby(...)
->limit(10)
->getQuery()
->execute();
$cloned = clone($builder);
$total = $cloned
->limit(null)
->getQuery()
->execute()
->count();