Table of Contents : The Manual

findAll

findAll(string $conditions, array $fields, string $order, int $limit, int $page, int $recursive);
  1. 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
                )
        )
)
  1. Array
  2. (
  3. [0] => Array
  4. (
  5. [ModelName] => Array
  6. (
  7. [id] => 83
  8. [field1] => value1
  9. [field2] => value2
  10. [field3] => value3
  11. )
  12. [AssociatedModelName] => Array
  13. (
  14. [id] => 1
  15. [field1] => value1
  16. [field2] => value2
  17. [field3] => value3
  18. )
  19. )
  20. [1] => Array
  21. (
  22. [ModelName] => Array
  23. (
  24. [id] => 85
  25. [field1] => value1
  26. [field2] => value2
  27. [field3] => value3
  28. )
  29. [AssociatedModelName] => Array
  30. (
  31. [id] => 2
  32. [field1] => value1
  33. [field2] => value2
  34. [field3] => value3
  35. )
  36. )
  37. )