->table()

->table() – Get or set the table schema

Synopsis

object $DB_DataObject->table ( array $schema )

Описание

Without any arguments, table() returns the table schema that the object deals with. With an array passed as the first argument, it will set the table schema for the current instance of the object.

The default schema is normally stored in the database.ini file described in the Autobuilding section.

Замечание

This function can not be called statically.

Пример

getting the connection

<?php
$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..!
?>
    Поддержать сайт на родительском проекте КГБ