In cakephp we might be familiar with the simple find("all") and findById() functions.
But fetching data with some conditions like we write select query with where condition.
lets us first look at simple find function
$this->User->find("all");
This function will fetch all the data from the model.But instead of all if we are required to fetch some data with some condition can be done as :
$this->User->find('all',
array('conditions'=>array('User.id'=>5)));
In the above we have set one condition in the function but we can set many.
Below is the list of other possible conditions we can set:
- type : 'first' can be 'all','first', or 'list'. it determines the type of operation to perform.
- fields : specifies which fields is to be retrieved.
- order : order by conditions. field name must be followed by ASC or DESC.
0 Comment(s)