예제 #1
0
파일: DbInit.php 프로젝트: sigma-z/dive
 public function initSchema()
 {
     $driver = $this->conn->getDriver();
     // (re)create tables
     $tableNames = $this->schema->getTableNames();
     $this->conn->disableForeignKeys();
     foreach ($tableNames as $tableName) {
         $this->dropTable($driver, $tableName);
         $this->createTable($driver, $tableName);
     }
     $this->conn->enableForeignKeys();
     // (re)create views
     $viewNames = $this->schema->getViewNames();
     $platform = $driver->getPlatform();
     foreach ($viewNames as $viewName) {
         $this->dropView($platform, $viewName);
         $this->createView($platform, $viewName);
     }
 }
예제 #2
0
 /**
  * @param Schema $schema
  * @return array
  */
 public function getNeededModels(Schema $schema)
 {
     $baseRecordClass = $schema->getRecordBaseClass();
     $tableNames = array_merge($schema->getTableNames(), $schema->getViewNames());
     foreach ($tableNames as $key => $tableName) {
         $recordClass = $schema->getRecordClass($tableName);
         if ($recordClass == $baseRecordClass) {
             unset($tableNames[$key]);
         } else {
             $tableNames[$key] = $recordClass;
         }
     }
     return $tableNames;
 }
예제 #3
0
파일: SchemaTest.php 프로젝트: sigma-z/dive
 public function testGetViewNames()
 {
     $expected = array('author_user_view');
     $actual = $this->schema->getViewNames();
     $this->assertEquals($expected, $actual);
 }