->tableName()

->tableName() -- オブジェクトのテーブル名を取得、あるいは設定する

概要

object $DB_DataObject->tableName ([string $name])

説明

引数なしの場合、オブジェクトが扱うテーブル名を返します。 文字列を渡した場合、そのオブジェクトが扱うテーブル名をセットします。

注意

この関数は、スタティックにコールする ことはできません。

例 33-1テーブル名の取得と設定


<?php
$person = new DataObjects_Person;
echo $person->tableName();
// echo's person


// now use the same object to query the extra_people table

$person->tableName('extra_people');
$person->id = 12;
$person->find(true);


// you can also use this in conjunction with table(), to create dataobjects for random tables..

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