예제 #1
0
파일: SchemaTest.php 프로젝트: sigma-z/dive
 public function testGetTableNames()
 {
     $expected = array('article', 'article2tag', 'author', 'comment', 'data_types', 'donation', 'tag', 'tree_node', 'unique_constraint_test', 'user');
     $actual = $this->schema->getTableNames();
     sort($actual);
     $this->assertEquals($expected, $actual);
 }
예제 #2
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);
     }
 }
예제 #3
0
 /**
  * @param string $modelClassName
  * @param Schema $schema
  * @return string
  */
 private function getTableName($modelClassName, Schema $schema)
 {
     $tableNames = $schema->getTableNames();
     foreach ($tableNames as $tableName) {
         if ($modelClassName == $schema->getRecordClass($tableName)) {
             return $tableName;
         }
     }
     return null;
 }