Guest User

Untitled

a guest
Apr 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. /**
  2. * Find one or more existing object, use optional filter to aide in search.
  3. * Example 7.
  4. * <code>
  5. * // Find and return all existing `Post` object, where `status` is 'pending' and `created` is a minimum date and time.
  6. * $filter = array(
  7. * 'status' => 'pending',
  8. * 'created >=' => date('Y-m-d H:i:s', strtotime('-48 Hours'))
  9. * );
  10. * $post = Post::findBy($filter);
  11. * print_r($post);
  12. *
  13. * // Get a list of no more than 20 `Visitor` from the 2nd page of a paged list, where `location` is 'CA' or 'US' and `language` is 'en', sort list by `logged` field in descending order.
  14. * // Wrap the `Visitor` data in an array.
  15. * $filter = array(
  16. * 'location' => array('CA', 'US'),
  17. * 'language' => 'en'
  18. * );
  19. * $option = array(
  20. * 'wrapper' => array()
  21. * );
  22. * $visitors = Visitor::findBy($filter, 'logged desc', 20, 2);
  23. * print_r($visitors);
  24. *
  25. * // Find all `Article` object, where `Article` has a `Tag` object with `name` value of 'dog' and an `Article` `created` value between two dates.
  26. * $filter = array(
  27. * 'created between' => array(date('Y-m-d H:i:s', strtotime('-30 days')), date('Y-m-d H:i:s'))),
  28. * 'Tag.name' => 'dog'
  29. * );
  30. * $articles = Article::findBy($filter);
  31. * print_r($articles);
  32. *
  33. * // Get `id` field value for the first 15 `House`, order by the `created` field in descending order, do not fetch any related object and wrap the data for each `House` in an object called `HouseId`.
  34. * $option = array(
  35. * 'field' => 'id',
  36. * 'recursion' => 0,
  37. * 'wrapper' => 'HouseId'
  38. * );
  39. * $house_id_list = House::findBy(array(), 'created desc', 15, 1, $option);
  40. * print_r($house_id_list);
  41. * </code>
  42. *
  43. * @param array $filter Optional filter that may be used to narrow objects that are returned.
  44. * @param array|string $order Order in which to begin return of first found object.
  45. * @param int $list_size Limit of the total number of found object that may be returned.
  46. * @param int $page Initial page from which to begin return of found objects, when a list size limit is imposed (default 1).
  47. * @param array $option ( [ array|string field [, int recursion [, array|string relation [, array|string wrapper ]]]] )
  48. * field : One or more data field belonging to a model, that should be returned.
  49. * recursion : Level of recursion that should occur when fetching related objects; 0 being none, 1 being directly related, 2 being directly related to directly related...etc. For full recursion use -1 (default 1).
  50. * relation : One or more directly related model that should be returned, if relation has an alias then the name of the alias should be used.
  51. * wrapper : Container that may be used for the data assoicated with each found object. If wrapper is to be an object, an array containing data will be passed as first argument when object is invoked.
  52. * @return array|object|null
  53. */
Add Comment
Please, Sign In to add comment