Public Member Functions | |
| RecordSelector ($where, $args, &$model) | |
| where () | |
| eq ($col, $val) | |
| match ($record) | |
| order ($orderby) | |
| limit ($num, $offset=0) | |
| fetch () | |
| count () | |
| load ($ret2d=false) | |
| load_all () | |
| load_one () | |
| one () | |
| delete () | |
| set ($key, $val=null) | |
| get () | |
| pair () | |
| _get_ids () | |
| _reset_state () | |
| _build_clause () | |
Public Attributes | |
| $model = null | |
| $sql_where = null | |
| $sql_order = null | |
| $sql_limit = null | |
| $it_ptr | |
| $id_cache | |
PRONTO WEB FRAMEWORK Copyright (C) 2006, Judd Vinet
Description: Auxiliary class for models, used to fluently assemble result sets that can be operated on with primitive data manipulation operations (get, set, fetch, load).
Definition at line 13 of file record_selector.php.
| RecordSelector::_build_clause | ( | ) |
Definition at line 336 of file record_selector.php.
| RecordSelector::_get_ids | ( | ) |
Definition at line 319 of file record_selector.php.
References assert_type().
Referenced by delete(), load(), load_one(), and set().
| RecordSelector::_reset_state | ( | ) |
Definition at line 330 of file record_selector.php.
Referenced by limit(), order(), RecordSelector(), and where().
| RecordSelector::count | ( | ) |
| RecordSelector::delete | ( | ) |
Delete one or more records.
Definition at line 216 of file record_selector.php.
References _get_ids().
| RecordSelector::eq | ( | $ | col, | |
| $ | val | |||
| ) |
A convenience method for RecordSelector::where(). Adds a WHERE clause that states "$col='$val'".
| string | $col The column to match. | |
| string | $val The value of the column. |
Definition at line 72 of file record_selector.php.
References where().
Referenced by match().
| RecordSelector::fetch | ( | ) |
Return one or more bare records. Each record will be an associative array. If multiple records are round, it will return an array of associative arrays.
Definition at line 131 of file record_selector.php.
References count().
| RecordSelector::get | ( | ) |
Get one or more column values from the result set. The return value varies:
1. If a single column is requested, then a scalar value will be returned. 2. If multiple columns are requested, then an associative array will be returned.
If more than one row matches, than an array of #1 or #2 will be returnd.
| string | Column name, ... |
Definition at line 264 of file record_selector.php.
References _build_clause(), and count().
| RecordSelector::limit | ( | $ | num, | |
| $ | offset = 0 | |||
| ) |
Add an additional LIMIT restriction to the result set
| int | $num Number of records to limit the result set to | |
| int | $offset Offset to start from (default 0, the beginning) |
Definition at line 117 of file record_selector.php.
References _reset_state().
| RecordSelector::load | ( | $ | ret2d = false |
) |
Return one or more full records. Each record will be an associative array. If multiple records are round, it will return an array of associative arrays.
| ret2d | boolean Always return an array of associative arrays, even if only one record was found. If zero recors are found, an empty array is returned. |
Definition at line 164 of file record_selector.php.
References _get_ids(), and count().
Referenced by load_all().
| RecordSelector::load_all | ( | ) |
Return one or more full records. The difference with load() is that this method always returns an array of associative arrays, even if only one matching record is found. Useful for callers that always expect a 2D array.
Definition at line 185 of file record_selector.php.
References load().
| RecordSelector::load_one | ( | ) |
Return one record, no matter how many are in the result set. This method uses an internal pointer to keep track of which record will be returned next, so you can call this method in an iterative fashion to process large results sets.
Definition at line 198 of file record_selector.php.
References _get_ids().
Referenced by one().
| RecordSelector::match | ( | $ | record | ) |
A convenience method for RecordSelector::where(). Look for record(s) that match all column values in the array.
| array | $record Associative array of column->value mappings that will be used as search criteria. |
Definition at line 84 of file record_selector.php.
References eq().
| RecordSelector::one | ( | ) |
| RecordSelector::order | ( | $ | orderby | ) |
Add an additional ORDER BY restriction to the result set
| string | $orderby "Order by" sub-clause |
Definition at line 99 of file record_selector.php.
References _reset_state().
| RecordSelector::pair | ( | ) |
Return a name-value-pair for the requested column(s).
| string | $key Column to use as the array key | |
| string | $val Column to use as the array value. If multiple values are passed, then the array value will be an associative array itself. |
Definition at line 300 of file record_selector.php.
| RecordSelector::RecordSelector | ( | $ | where, | |
| $ | args, | |||
| &$ | model | |||
| ) |
Build a new RecordSelector object that can be used to operate on a subset of records from the model's table. This constructor should only be called from within a data model object.
| $where | string Where clause | |
| $args | array Query arguments to substitute | |
| $model | object The model object creating this selector |
Definition at line 33 of file record_selector.php.
References $args, $model, and _reset_state().
| RecordSelector::set | ( | $ | key, | |
| $ | val = null | |||
| ) |
Set the value of one or more columns.
| mixed | $key Column name. To set multiple columns, pass an associative array of all column=>value mappings. | |
| mixed | $val Column value. Only used if setting a single column value. |
Definition at line 231 of file record_selector.php.
References $args, _build_clause(), and _get_ids().
| RecordSelector::where | ( | ) |
Add an additional WHERE restriction to the result set
| string | "Where" sub-query (leave blank to select all) | |
| mixed | Additional query argument (optional) | |
| mixed | Additional query argument (optional) ... |
Definition at line 50 of file record_selector.php.
References $args, and _reset_state().
Referenced by eq().
| RecordSelector::$id_cache |
Definition at line 22 of file record_selector.php.
| RecordSelector::$it_ptr |
Definition at line 21 of file record_selector.php.
| RecordSelector::$model = null |
Definition at line 15 of file record_selector.php.
Referenced by RecordSelector().
| RecordSelector::$sql_limit = null |
Definition at line 19 of file record_selector.php.
| RecordSelector::$sql_order = null |
Definition at line 18 of file record_selector.php.
| RecordSelector::$sql_where = null |
Definition at line 17 of file record_selector.php.
1.6.1