Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limit sql in Cakephp find function

Tags:

cakephp

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 ...

like image 228
rajesh Avatar asked Aug 27 '11 10:08

rajesh


People also ask

What is the function of limit in SQL?

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.

How can I get data from CakePHP?

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()

How can I print query in CakePHP 2?

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.

How can I order in CakePHP?

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.


1 Answers

Better way: $this->Emp->find('all', array('limit'=>4, 'offset'=>3);

like image 174
hasentopf Avatar answered Oct 01 '22 15:10

hasentopf