return_row
return_row
A base class for database-driven models.
It wraps around the PDO library, and provides some very simplistic ORM capabilities. You don't have to use them, but if you want them they are there. The built-in ORM represents a single table. For more advanced methods such a multi-table support, you can use the query() method directly and write methods in your extended class.
newChild( $data = array())
Get an instance of our child class, representing a row.
This is used by wrapRow() for existing rows, and can be used directly to return a child row with no primary key set, that can be inserted into the database using $row->save();
If the known_fields class member is set, it will be used to ensure all of the known fields are passed to the child class with some form of default value (if not specified in the known_fields array, the default value depends on the $this->default_null setting.)
| $data |
getRowByFields( $fields, $ashash = False, $cols = '*')
Get a single row based on the value of multiple fields.
This is a simple AND based approach, and uses = as the comparison. If you need anything more complex, write your own method, or use getRowWhere() instead.
| $fields | ||
| $ashash | ||
| $cols |
newRow( $row, $opts = array())
Insert a new row.
Note this does no checking to ensure the specified fields are valid, so wrap this in your own classes with more specific versions. It's also not recommended that you include the primary key field, as it should be auto generated by the database. To this end, by default we disallow the primary key field. As the output of an insert is not consistent we just return the query object, if you're at all interested.
| $row | ||
| $opts |