DB_DataObject

サンプル

  1. example.iniをコピー
    $ cp /usr/share/pear/docs/DB_DataObject/docs/example.ini test.ini
  2. test.ini を編集し、解析先DBの情報に変更する
    database=pgsql://postgres@127.0.0.1/test
    schema_location=/var/www/html/test
    class_location=/var/www/html/test
    db_driver=DB
    +createTables.php で既存のDBを解析し、クラスを作成する
    $ php -q /usr/share/pear/DB/DataObject/createTables.php /var/www/html/test/test.ini
  3. サンプルソース
    <?
    require_once('DB/DataObject.php');
    $options = &PEAR::getStaticProperty('DB_DataObject','options');
    $options = array(
              'database'=>'pgsql://postgres@127.0.0.1/test',
              'schema_location'  => '/var/www/html/test',
              'class_location'   => '/var/www/html/test',
              'class_prefix'     => 'DataObjects_',
              'debug'=>0
                 );
    
    $o = DB_DataObject::factory('public.ads_master');
    $o->find();
    while($o->fetch()){
            echo "{$o->ads_id} | {$o->ads}<br/>\n";
    }
    ?>
    

関連リンク


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2018-09-15 (土) 07:31:38