How can I use limit in sql in cakephp...I mean follwoing is the sql...
select * from emp limit 3,4
How can use above limit [3,4] in find function ...
The LIMIT clause is used to set an upper limit on the number of tuples returned by SQL. It is important to note that this clause is not supported by all SQL versions. The LIMIT clause can also be specified using the SQL 2008 OFFSET/FETCH FIRST clauses. The limit/offset expressions must be a non-negative integer.
When you want to grab associated data, or filter based on associated data, there are two ways: use CakePHP ORM query functions like contain() and matching() use join functions like innerJoin() , leftJoin() , and rightJoin()
Add below line in your model where you want print query. $last_query = $ this ->ModelName->getLastQuery(); As we have saved last executed query in variable $last_query then use this to print last executed query.
To apply ordering, you can use the order method: $query = $articles->find() ->order(['title' => 'ASC', 'id' => 'ASC']); When calling order() multiple times on a query, multiple clauses will be appended.
Better way: $this->Emp->find('all', array('limit'=>4, 'offset'=>3);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With