Fix formatting and expand find() docs.

This commit is contained in:
mark_story 2013-02-26 22:00:55 -05:00
parent d9fbe5e00a
commit 1d3095ece5

View file

@ -2611,19 +2611,20 @@ class Model extends Object implements CakeEventListener {
/** /**
* Queries the datasource and returns a result set array. * Queries the datasource and returns a result set array.
* *
* Also used to perform notation finds, where the first argument is type of find operation to perform * Used to perform find operations, where the first argument is type of find operation to perform
* (all / first / count / neighbors / list / threaded), * (all / first / count / neighbors / list / threaded),
* second parameter options for finding ( indexed array, including: 'conditions', 'limit', * second parameter options for finding ( indexed array, including: 'conditions', 'limit',
* 'recursive', 'page', 'fields', 'offset', 'order') * 'recursive', 'page', 'fields', 'offset', 'order', 'callbacks')
* *
* Eg: * Eg:
* {{{ * {{{
* find('all', array( * $model->find('all', array(
* 'conditions' => array('name' => 'Thomas Anderson'), * 'conditions' => array('name' => 'Thomas Anderson'),
* 'fields' => array('name', 'email'), * 'fields' => array('name', 'email'),
* 'order' => 'field3 DESC', * 'order' => 'field3 DESC',
* 'recursive' => 2, * 'recursive' => 2,
* 'group' => 'type' * 'group' => 'type',
* 'callbacks' => false,
* )); * ));
* }}} * }}}
* *
@ -2632,32 +2633,43 @@ class Model extends Object implements CakeEventListener {
* joins that should be part of the query. * joins that should be part of the query.
* *
* {{{ * {{{
* find('all', array( * $model->find('all', array(
* 'conditions' => array('name' => 'Thomas Anderson'), * 'conditions' => array('name' => 'Thomas Anderson'),
* 'joins' => array( * 'joins' => array(
* array( * array(
* 'alias' => 'Thought', * 'alias' => 'Thought',
* 'table' => 'thoughts', * 'table' => 'thoughts',
* 'type' => 'LEFT', * 'type' => 'LEFT',
* 'conditions' => '`Thought`.`person_id` = `Person`.`id`' * 'conditions' => '`Thought`.`person_id` = `Person`.`id`'
* ) * )
* ) * )
* )); * ));
* }}} * }}}
* *
* ### Disabling callbacks
*
* The `callbacks` key allows you to disable or specify the callbacks that should be run. To
* disable beforeFind & afterFind callbacks set `'callbacks' => false` in your options. You can
* also set the callbacks option to 'before' or 'after' to enable only the specified callback.
*
* ### Adding new find types
*
* Behaviors and find types can also define custom finder keys which are passed into find(). * Behaviors and find types can also define custom finder keys which are passed into find().
* See the documentation for custom find types
* (http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#creating-custom-find-types)
* for how to implement custom find types.
* *
* Specifying 'fields' for notation 'list': * Specifying 'fields' for notation 'list':
* *
* - If no fields are specified, then 'id' is used for key and 'model->displayField' is used for value. * - If no fields are specified, then 'id' is used for key and 'model->displayField' is used for value.
* - If a single field is specified, 'id' is used for key and specified field is used for value. * - If a single field is specified, 'id' is used for key and specified field is used for value.
* - If three fields are specified, they are used (in order) for key, value and group. * - If three fields are specified, they are used (in order) for key, value and group.
* - Otherwise, first and second fields are used for key and value. * - Otherwise, first and second fields are used for key and value.
* *
* Note: find(list) + database views have issues with MySQL 5.0. Try upgrading to MySQL 5.1 if you * Note: find(list) + database views have issues with MySQL 5.0. Try upgrading to MySQL 5.1 if you
* have issues with database views. * have issues with database views.
* *
* Note: find(count) has its own return values. * Note: find(count) has its own return values.
* *
* @param string $type Type of find operation (all / first / count / neighbors / list / threaded) * @param string $type Type of find operation (all / first / count / neighbors / list / threaded)
* @param array $query Option fields (conditions / fields / joins / limit / offset / order / page / group / callbacks) * @param array $query Option fields (conditions / fields / joins / limit / offset / order / page / group / callbacks)