cakephp-1.3 > Model :: find()
Model
- __collectForeignKeys
- __construct
- __constructLinkedModel
- __createLinks
- __filterResults
- __generateAssociation
- __save
- __saveMulti
- __sleep
- __validateWithModels
- __wakeup
- _clearCache
- _deleteDependent
- _deleteLinks
- _findCount
- _findFirst
- _findList
- _findNeighbors
- _findThreaded
- _prepareUpdateFields
- &getDataSource
- afterDelete
- afterFind
- afterSave
- beforeDelete
- beforeFind
- beforeSave
- beforeValidate
- bindModel
- call__
- create
- deconstruct
- delete
- deleteAll
- escapeField
- exists
- field
- find
- getAffectedRows
- getAssociated
- getColumnType
- getColumnTypes
- getID
- getInsertID
- getLastInsertID
- getNumRows
- getVirtualField
- hasAny
- hasField
- invalidate
- invalidFields
- isForeignKey
- isUnique
- isVirtualField
- joinModel
- onError
- query
- read
- resetAssociations
- save
- saveAll
- saveField
- schema
- set
- setDataSource
- setInsertID
- setSource
- unbindModel
- updateAll
- updateCounterCache
- validates
A
AclBase
AclBehavior
AclComponent
AclNode
AclShell
Aco
AcoAction
AjaxHelper
ApcEngine
ApiShell
App
AppController
AppController
AppHelper
AppHelper
AppModel
AppModel
Aro
AuthComponent
B
BakeShell
BakeTask
BehaviorCollection
C
Cache
CacheEngine
CacheHelper
CakeErrorController
CakeLog
CakeRoute
CakeSchema
CakeSession
CakeSocket
ClassRegistry
Component
Configure
ConnectionManager
ConsoleShell
ContainableBehavior
Controller
ControllerTask
CookieComponent
D
DataSource
DbAcl
DbAclSchema
DbConfigTask
DboMssql
DboMysql
DboMysqlBase
DboMysqli
DboOracle
DboPostgres
DboSource
DboSqlite
Debugger
Dispatcher
E
EmailComponent
ErrorHandler
ErrorHandler
ExtractTask
F
File
FileEngine
FileLog
FixtureTask
Folder
FormHelper
H
Helper
HtmlHelper
HttpSocket
I
I18n
I18nModel
i18nSchema
I18nShell
Inflector
IniAcl
J
JavascriptHelper
JqueryEngineHelper
JsBaseEngineHelper
JsHelper
L
L10n
M
MagicDb
MagicFileResource
MediaView
MemcacheEngine
Model
ModelBehavior
ModelTask
MootoolsEngineHelper
Multibyte
N
NumberHelper
O
Object
Overloadable
Overloadable
Overloadable2
Overloadable2
P
PagesController
PagesController
PaginatorHelper
Permission
PluginShortRoute
PluginTask
ProjectTask
PrototypeEngineHelper
R
RequestHandlerComponent
Router
RssHelper
S
Sanitize
Scaffold
ScaffoldView
SchemaShell
Security
SecurityComponent
SessionComponent
SessionHelper
SessionsSchema
Set
Shell
ShellDispatcher
String
T
TemplateTask
TestSuiteShell
TestTask
TextHelper
ThemeView
TimeHelper
TranslateBehavior
TreeBehavior
V
Validation
View
ViewTask
X
XcacheEngine
Xml
XmlElement
XmlHelper
XmlManager
XmlNode
XmlTextNode
find
line:2085 at
/cake/libs/model/model.php
Queries the datasource and returns a result set array.
Method
(array)
find
($conditions = null, $fields = array(), $order = null, $recursive = null)
Parameters
Parameter | Type | Comment | Default |
---|---|---|---|
$conditions | array | optional SQL conditions array, or type of find operation (all / first / count / neighbors / list / threaded) | null |
$fields | mixed | optional Either a single string of a field name, or an array of field names, or options for matching | array() |
$order | string | optional SQL ORDER BY conditions (e.g. "price DESC" or "name ASC") | null |
$recursive | integer | optional The number of levels deep to fetch associated records | null |
Return
arrayComment
Queries the datasource and returns a result set array.
Also used to perform new-notation finds, where the first argument is type of find operation to perform
(all / first / count / neighbors / list / threaded ),
second parameter options for finding ( indexed array, including: 'conditions', 'limit',
'recursive', 'page', 'fields', 'offset', 'order')
Eg:
{{{
find('all', array(
'conditions' => array('name' => 'Thomas Anderson'),
'fields' => array('name', 'email'),
'order' => 'field3 DESC',
'recursive' => 2,
'group' => 'type'
));
}}}
In addition to the standard query keys above, you can provide Datasource, and behavior specific
keys. For example, when using a SQL based datasource you can use the joins key to specify additional
joins that should be part of the query.
{{{
find('all', array(
'conditions' => array('name' => 'Thomas Anderson'),
'joins' => array(
array(
'alias' => 'Thought',
'table' => 'thoughts',
'type' => 'LEFT',
'conditions' => '`Thought`.`person_id` = `Person`.`id`'
)
)
));
}}}
Behaviors and find types can also define custom finder keys which are passed into find().
Specifying 'fields' for new-notation 'list':
- 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 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.
Note: find(list) + database views have issues with MySQL 5.0. Try upgrading to MySQL 5.1 if you
have issues with database views.
@param array $conditions SQL conditions array, or type of find operation (all / first / count /
neighbors / list / threaded)
@param mixed $fields Either a single string of a field name, or an array of field names, or
options for matching
@param string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC")
@param integer $recursive The number of levels deep to fetch associated records
@return array Array of records
@access public
@link http://book.cakephp.org/view/1018/find
Also used to perform new-notation finds, where the first argument is type of find operation to perform
(all / first / count / neighbors / list / threaded ),
second parameter options for finding ( indexed array, including: 'conditions', 'limit',
'recursive', 'page', 'fields', 'offset', 'order')
Eg:
{{{
find('all', array(
'conditions' => array('name' => 'Thomas Anderson'),
'fields' => array('name', 'email'),
'order' => 'field3 DESC',
'recursive' => 2,
'group' => 'type'
));
}}}
In addition to the standard query keys above, you can provide Datasource, and behavior specific
keys. For example, when using a SQL based datasource you can use the joins key to specify additional
joins that should be part of the query.
{{{
find('all', array(
'conditions' => array('name' => 'Thomas Anderson'),
'joins' => array(
array(
'alias' => 'Thought',
'table' => 'thoughts',
'type' => 'LEFT',
'conditions' => '`Thought`.`person_id` = `Person`.`id`'
)
)
));
}}}
Behaviors and find types can also define custom finder keys which are passed into find().
Specifying 'fields' for new-notation 'list':
- 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 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.
Note: find(list) + database views have issues with MySQL 5.0. Try upgrading to MySQL 5.1 if you
have issues with database views.
@param array $conditions SQL conditions array, or type of find operation (all / first / count /
neighbors / list / threaded)
@param mixed $fields Either a single string of a field name, or an array of field names, or
options for matching
@param string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC")
@param integer $recursive The number of levels deep to fetch associated records
@return array Array of records
@access public
@link http://book.cakephp.org/view/1018/find