Exemplo n.º 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;
             }
         }
     }
 }
Exemplo n.º 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]);
             }
         }
     }
 }