databaseList

Disclaimer: This class is horrible! I know it’s horrible. There is not much use for it when dealing with large data sets, but it’s handy for creating HTML from a list of records in a database, etc for things like a HTML select statement, etc.

Implements a list of table objects.

Parent Class

None


Public Properties

$tableName
The name of the table you passed at instantiation
Data Type: string
Default Value: Empty string
$records
An array of table objects
Data Type: array
Default Value: Empty array

Public Methods

\ipinga\databaseList __construct( string $tableName )
This is the class constructor.
Parameters:
$tableName (string: required) is the name of the database table you will be using to build this databaseList
Returns:
A databaseList instance
Example:
void load( [string $orderBy] )
Loads the records from the database into this databaseList object.
Parameters:
$orderBy (string: optional) is the field name to order the records by. Default: id
Returns:
null
Example:
void loadWithWhere( string $where [, string $orderBy] )
Loads the records from the database into this databaseList object.
Parameters:
$where (string: required) is the where clause used to load the records
$orderBy (string: optional) is the field name to order the records by. Default: id
Returns:
null
Example:
void filter( array $filter )
Filters (removes) records from the databaseList that do not match the required filter
Parameters:
$filter is an associate array of fieldnames and values to use as the filter
Returns:
null
Example:
string asHtmlSelect( string $selectName, string $fieldName[, integer $selectedId [, boolean $addFirst [, string $class ]]])
Returns a string representation for a HTML select statement, using the records in this databaseList
Parameters:
$selectName (string: required) is the value that will be used as the HTML select’s name attribute
$fieldName (string: required) is the name of the field to display as a choice for the user
$selectedId (integer: optional) is the id value for the currently selected record. Default=0
$addFirst (boolean: optional) if true will cause the phrase “Select one…” to be added as the first option statement in the HTML select code. Default=false
$class (string: optional) is the value that will be used as the HTML select’s class attribute. Default=none
Returns:
An HTML string of code that is the select statement
Example:
string asJson()
Returns a json_encoded string of all the record’s field values
Parameters:
None.
Returns:
A json encoded string
Example:
\ipinga\table|boolean recordByField( string $fieldName, mixed $value )
Locates a record in the databaseList
Parameters:
$fieldName (string: required) is the name of the field to test
$value (mixed: required) is the value to select from the records
Returns:
A table object for the record that matches the $value or false if no record is found
Example:
integer recordNumberByField( string $fieldName, mixed $value )
Locates a record in the databaseList. This is very similar to the function above, but returns the record id instead of the actual record.
Parameters:
$fieldName (string: required) is the name of the field to test
$value (mixed: required) is the value to select from the records
Returns:
An integer value for the id field of the record that was located, or zero if no record was found.
Example: