Finding saved records
The "find" method return an instance of "PorteIterator" which can be manipulated like an iteration of records. The method is available in "PorteRecord" and "PorteTable" objects.
Available options
The properties available in the options array are:
- "sql" (string, may contains ?)
- "params" (array, match sql ?)
- "tables" (array or string list)
- "select" (select query)
- "where" (where query)
- "order_by" (field name)
- "group_by" (field name)
- "having" (string)
- "direction" (asc or desc)
- "limit" (int or string)
- "offset" (int or string)
- "return_sql" (boolean) Return the SQL query used to select the records
- "return_builder" (boolean) Return an array containing the keys "select", "from", "where", "group_by", "having", "order_by" ,"direction" and "limit"
- "return_array" (boolean) Return an array of arrays instead of PorteIterator object of PorteRecord objects
Exemples
Exemples on using the find method
// return and array of users based on a where query
$user->find('username=? AND password=?',array(
'my username',
'my password'
));
// return and array of users based on options
$user->find(array(
'order_by'=>'date_of_creation',
'direction'=>'asc'
));
// return and array of users based on a where query and options
$user->find('group_id=?',array(4),array(
'order_by'=>'date_of_creation',
'direction'=>'asc'
));