->table() -- Get or set the table schema
Description
Without any argument, it returns the table schema that the object deals with. With an array, it will
set the table schema for the instance of the object.
The default schema is normally stored in the database.ini file described in the Autobuilding section.
Note
This function can not be called
statically.
Example
Example 26-1. getting the connection $person = new DataObjects_Person;
print_r($person->table());
//
// array(
// 'id' => 1 // == DB_DATAOBJECT_INT
// 'name' => 2 // == DB_DATAOBJECT_STR
// 'bday' => 6 // == DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE
// 'last' => 14 // == DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME
// 'active' => 17 // == DB_DATAOBJECT_INT + DB_DATAOBJECT_BOOL
// 'desc' => 34 // == DB_DATAOBJECT_STR + DB_DATAOBJECT_TXT
// 'photo' => 64 // == DB_DATAOBJECT_STR + DB_DATAOBJECT_BLOB
// )
//
// now use it to define a on the fly database table...
$d = new DB_DataObject;
$d->tableName('person');
$d->table(array(
'id' => DB_DATAOBJECT_INT,
'name' => DB_DATAOBJECT_STRING,
));
$d->keys(array('id'));
$d->id = 12;
$d->find(true);
// should do the same as above..! |
|