Class Record
Base class that represents a record in a table.
Extend this class and add a property $table that is equal to the table name in your database. The columns will be loaded automatically and basic load(), save(), and delete() methods are immediately available. Update the data by changing the value of the columns like this:
Usage
// load a record with id= 5 from a table called 'user' class user extends \Module\DB\Record { public $table = 'user'; } $u = new user(); $u->load(5); $u->columns['first_name'] = 'Joe';
You can then save the new information by calling the save method:
$u->save();
You can also show a nice form to edit or add new records like this
$u->form(array( 'first_name' => 'First Name: ', 'last_name' => 'Last Name: ', 'phone' => '(800) 555-5555' ));
Changelog
Version 1.2
- Added namespacing
Version 1.1
- Added the date section to the documentation
Direct known subclasses
Module\Authentication\Permission, Module\Authentication\Role, Module\Authentication\User, Module\Authentication\UserMeta
Namespace: Module\DB
License: http://opensource.org/licenses/MIT
Author: Jaime A. Rodriguez hi.i.am.jaime@gmail.com
Version: 1.1
Date: June 16, 2014
Section:
Located at class.record.php
License: http://opensource.org/licenses/MIT
Author: Jaime A. Rodriguez hi.i.am.jaime@gmail.com
Version: 1.1
Date: June 16, 2014
Section:
dependencies Dependencies * class.hooks.php * class.db.php
Located at class.record.php
public
|
|
public
boolean
|
|
public
mixed
|
|
public
boolean
|
|
public
|
protected
|
$db
PDO The PDO object |
|
protected
|
$table
string The name of the table |
|
protected
string
|
$primaryKey
string The primary key of the table |
#
'id'
|
public
|
$columns
array The data of the record get loaded here |
|
public
|
$meta
stdObject The record meta data gets loaded here |