Fakoli Framework
query.inc File Reference

Go to the source code of this file.

Classes

class  AbstractQuery
 
class  Query
 Query provides an object-oriented interface for database queries. More...
 

Functions

 query ($class)
 Performs a query against the database, returning an array of DataItem objects of the specified class. More...
 

Function Documentation

◆ query()

query (   $class)

Performs a query against the database, returning an array of DataItem objects of the specified class.

Parameters
string$classthe name of the class of objects to query
$constraintsoptional constraint clause to apply to the query in the form "WHERE ... [ORDER BY ...]"
$filteroptional filter to apply to the query
$pageoptional page number to retrieve
$sizeoptional size of pages

Definition at line 360 of file query.inc.

361 {
362  $query = new Query($class);
363 
364  if (func_num_args() > 1)
365  {
366  $idx = 1;
367 
368  if (is_object(func_get_arg(1)))
369  {
370  $query->filter($filter);
371  ++$idx;
372  }
373 
374  if (is_array(func_get_arg($idx)))
375  {
376  $query->params(func_get_arg($idx++));
377  }
378 
379  if (func_num_args() > $idx)
380  {
381  $query->constraints(func_get_arg($idx));
382 
383  if (func_num_args() == $idx + 3)
384  {
385  $query->page(func_get_arg($idx + 1), func_get_arg($idx + 2));
386  }
387  }
388  }
389 
390  return $query->execute();
391 }
Query provides an object-oriented interface for database queries.
Definition: query.inc:112