SQL_Generator Class Reference

List of all members.

Public Member Functions

 SQL_Generator (&$page)
 enumerate ($params, $set_vars=false)
 filter ($exprs=array(), $gexprs=array())
 sort ($default, $exprs=array())
 paginate ($perpage=50)

Public Attributes

 $db
 $page

Detailed Description

PRONTO WEB FRAMEWORK Copyright (C) 2006, Judd Vinet

Author:
Judd Vinet <jvinet at="" zeroflux="" dot="" org>="">

Description: SQL Generator Methods. Intended to be used by page controllers only.

Definition at line 12 of file sql.php.


Member Function Documentation

SQL_Generator::enumerate ( params,
set_vars = false 
)

Generate SQL to enumerate the records of an entity, returning the resulting rows and related pagination data.

Parameters:
array $params Parameters that will be used to generate the resulting SQL. These parameters are typically provided by the entity's model, usually in a method called list_params().
boolean $set_vars Automatically set template variables: (data, totalrows, curpage, perpage)
Returns:
array An array of: (data, total rows, current page, records per page)

Definition at line 38 of file sql.php.

References $args, $params, assert_type(), filter(), paginate(), and sort().

SQL_Generator::filter ( exprs = array(),
gexprs = array() 
)

Generate SQL to filter a result set based on filter variables in _REQUEST. This can generate SQL that can be used in a WHERE or HAVING clause.

Parameters:
array $exprs An array of expressions that do not correspond to real table columns, but to more complex statements that involve functions (eg, LENGTH(colname) or COUNT(c.id)). Each array key should be the "column" name used in the filter variable in _REQUEST.
Returns:
array The resulting SQL fragment and the corresponding SQL arguments eg, array(where_sql, where_args, having_sql, having_args)

Definition at line 113 of file sql.php.

References $args.

Referenced by enumerate().

SQL_Generator::paginate ( perpage = 50  ) 

Generate SQL to paginate a result set. Also sets the "perpage" and "curpage" variables in the template.

Parameters:
int $perpage Number of records to show per page
Returns:
string The resulting SQL fragment

Definition at line 277 of file sql.php.

References $page.

Referenced by enumerate().

SQL_Generator::sort ( default,
exprs = array() 
)

Generate SQL to sort a result set based on sort variables in _REQUEST

Parameters:
string $default Default column(s) to sort by
array $exprs An array of expressions that do not correspond to real table columns, but to more complex statements that involve functions (eg, LENGTH(colname) or COUNT(c.id)). Each array key should be the "column" name used in the filter variable in _REQUEST.
Returns:
string The resulting SQL fragment

Definition at line 233 of file sql.php.

References $p.

Referenced by enumerate().

SQL_Generator::SQL_Generator ( &$  page  ) 

Constructor

Parameters:
object $page The controller object that owns this instance of SQL_Generator

Definition at line 22 of file sql.php.

References $page, and Registry::get().


Member Data Documentation

SQL_Generator::$db

Definition at line 14 of file sql.php.

SQL_Generator::$page

Definition at line 15 of file sql.php.

Referenced by paginate(), and SQL_Generator().


The documentation for this class was generated from the following file:

Generated on Wed Jan 13 09:21:05 2010 for Pronto Framework by  doxygen 1.6.1