예제 #1
0
파일: SchemaTest.php 프로젝트: sigma-z/dive
 public function testToArray()
 {
     $tableNames = array_keys($this->schemaDefinition['tables']);
     $viewNames = array_keys($this->schemaDefinition['views']);
     $relationNames = array_keys($this->schemaDefinition['relations']);
     $actual = $this->schema->toArray();
     $this->assertEquals($tableNames, array_keys($actual['tables']));
     $this->assertEquals($viewNames, array_keys($actual['views']));
     $this->assertEquals($relationNames, array_keys($actual['relations']));
 }
예제 #2
0
 /**
  * @param string $tableName
  */
 private function initTableBehaviors($tableName)
 {
     $behaviors = $this->schema->getTableBehaviors($tableName);
     foreach ($behaviors as $behaviorDefinition) {
         $behavior = $this->getBehaviorInstance($behaviorDefinition);
         $this->getEventDispatcher()->addSubscriber($behavior);
         if (!empty($behaviorDefinition['config'])) {
             $behavior->setTableConfig($tableName, $behaviorDefinition['config']);
         }
     }
 }
예제 #3
0
파일: Migration.php 프로젝트: sigma-z/dive
 /**
  * @param Schema $schema
  */
 public function importFromSchema(Schema $schema)
 {
     $this->columns = $schema->getTableFields($this->tableName);
     $this->indexes = $schema->getTableIndexes($this->tableName);
     $foreignKeys = $schema->getTableRelations($this->tableName);
     /** @var array[] $owningRelations */
     $owningRelations = $foreignKeys['owning'];
     foreach ($owningRelations as $definition) {
         $owningField = $definition['owningField'];
         $this->foreignKeys[$owningField] = array('refTable' => $definition['refTable'], 'refField' => $definition['refField'], 'onDelete' => isset($definition['onDelete']) ? $definition['onDelete'] : null, 'onUpdate' => isset($definition['onUpdate']) ? $definition['onUpdate'] : null);
     }
 }
예제 #4
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;
 }
예제 #5
0
파일: DbInit.php 프로젝트: sigma-z/dive
 /**
  * (re)create view
  *
  * @param PlatformInterface $platform
  * @param string            $viewName
  */
 private function createView(PlatformInterface $platform, $viewName)
 {
     $sqlStatement = $this->schema->getViewStatement($viewName);
     $sql = $platform->getCreateViewSql($viewName, $sqlStatement);
     $this->conn->exec($sql);
 }