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

->keys()

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

->keys()

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

Synopsis

array $DB_DataObject->keys ( string $keys ... )

Without any arguments, keys() returns an array of the keys used by the object (the generator builds these and guesses them based on finding things like primary key, unique, or nextval). Calling it with a value, or mulitple values, sets the keys for the current instance of the object.

The default keys are 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->keys());
//
// array(
//     0 => 'id',
// )
//


 

// 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('id');

// if you have multiple keys
// $d->keys('id','key2','key2');


$d->id 12;
$d->find(true);
// should do the same as above..!
?>


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

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