예제 #1
0
 static function run(Orm\Scaffold &$scaffold)
 {
     $sql = "SELECT type, name from sqlite_master where  type in ('table', 'view') and name <> 'sqlite_sequence'";
     $stmt = $scaffold->getDb()->prepare($sql);
     $stmt->execute();
     $rows = (array) $stmt->fetchAll();
     if (count($rows) > 0) {
         foreach ($rows as $row) {
             switch ($row['type']) {
                 case 'table':
                     $scaffold->addTable($row['name']);
                     break;
                 case 'view':
                     $scaffold->addView($row['name']);
                     break;
             }
         }
     }
 }
예제 #2
0
 private static function _getObjects($type, Orm\Scaffold &$scaffold)
 {
     $sql = "select * from pg_catalog.pg_{$type} where schemaname=:SCHEMA";
     $stmt = $scaffold->getDb()->prepare($sql);
     $schema = $scaffold->getSchema();
     $stmt->bindParam(':SCHEMA', $schema);
     $stmt->execute();
     $rows = (array) $stmt->fetchAll();
     if (count($rows) > 0) {
         foreach ($rows as $row) {
             if ($type == 'views') {
                 $key = 'viewname';
                 $scaffold->addView($row[$key]);
             } else {
                 $key = 'tablename';
                 $scaffold->addTable($row[$key]);
             }
         }
     }
 }
예제 #3
0
<?php

// http://Nov2/tests/orm/scaffold.php
error_reporting(-1);
require_once "Nov/Loader.php";
\Nov\Loader::init();
use Nov\Db\Orm;
$scaffold = new Orm\Scaffold(Nov\Db::factory(NovConf::PG1), 'test');
$scaffold->buildAll(NovBASEPATH . '/Orm');
/*
$db = Nov_Db::singleton(Conf_Db::PG1);

$data = Orm_Pg1_demo_tblerislog::factory($db)->select()->exec();
$scaffold = new Nov_Db_Orm_Scaffold($db, 'Pg1');

$scaffold->addTable('demo.tblerislog');

$scaffold->buildAll(NovBASEPATH.'Orm');
*/