findAll
findAll(string $conditions, array $fields, string $order, int $limit, int $page, int $recursive);
findAll(string $conditions, array $fields, string $order, int $limit, int $page, int $recursive);
Returns the specified fields up to $limit records matching $conditions (if any), start listing from page $page (default is page 1). If there are no matching fields, an empty array is returned.
The $conditions should be formed just as they would in an SQL statement: $conditions = "Pastry.type LIKE '%cake%' AND Pastry.created_on > ‘2007-01-01’", for example. Prefixing conditions with the model’s name (‘Pastry.type’ rather than just ‘type’) is always a good practice, especially when associated data is being fetched in a query.
Setting the $recursive parameter to an integer forces findAll() to fetch data according to the behavior described in the Model Attributes $recursive section outlined earlier.
Data from findAll() is returned in an array, following this basic format:
Array
(
[0] => Array
(
[ModelName] => Array
(
[id] => 83
[field1] => value1
[field2] => value2
[field3] => value3
)
[AssociatedModelName] => Array
(
[id] => 1
[field1] => value1
[field2] => value2
[field3] => value3
)
)
[1] => Array
(
[ModelName] => Array
(
[id] => 85
[field1] => value1
[field2] => value2
[field3] => value3
)
[AssociatedModelName] => Array
(
[id] => 2
[field1] => value1
[field2] => value2
[field3] => value3
)
)
)
Array([0] => Array([ModelName] => Array([id] => 83[field1] => value1[field2] => value2[field3] => value3)[AssociatedModelName] => Array([id] => 1[field1] => value1[field2] => value2[field3] => value3))[1] => Array([ModelName] => Array([id] => 85[field1] => value1[field2] => value2[field3] => value3)[AssociatedModelName] => Array([id] => 2[field1] => value1[field2] => value2[field3] => value3)))

login to add a comment