Comments: find

By primeminister on 20/8/08

1 - Adding remark to find('count')

When using find('count') you don't use the 'fields' array in the options, otherwise it won;t return anything or null.

By sneeka2 on 25/8/08

2 - find('threaded')

The find type 'threaded' doesn't actually seem to be supported as of 1.2 RC2. A different method called findAllThreaded() is though. Needless to say this requires the model to be a Tree of some sort.

By shepard8 on 7/9/08

3 - order direction

To specify the order direction (i.e. ASC ou DESC), just add it into the 'order' param.

For example:

$this->Post->find('all', array('order' => 'Post.created DESC'))

There is no proper parameter to do that.

By chrisjenx2001 on 21/9/08

4 - Order Associated

By the looks of it you cant order associated data.

By mathie 2 weeks, 6 days ago

5 - Example of find('count')

As a beginner to CakePHP, I find examples much easier to learn than reading the full param specs. This is a simple example of find('count') to check if a username has been taken (count>0) or not (count==0).

$vCond = array('User.username'=>$this->data['User']['username']);

if ($this->find('count',array('conditions'=>$vCond))>0) {

// username taken

}