Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 23052 программиста и 2046 роботов. Сейчас ищут 1318 программистов ...

->table()

Вернуться к: DB_DataObject

->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.

Note

This function can not be called statically.

Example

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..!
?>


Вернуться к: DB_DataObject

© 2025 «PHP.RU — Сообщество PHP-Программистов»
Главная | Форум | Реклама на сайте | Контакты VIP Сувениры
Разработка компании ODware