当前位置: 首页>>代码示例>>PHP>>正文


PHP Table::hasColumn方法代码示例

本文整理汇总了PHP中Doctrine\DBAL\Schema\Table::hasColumn方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::hasColumn方法的具体用法?PHP Table::hasColumn怎么用?PHP Table::hasColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\DBAL\Schema\Table的用法示例。


在下文中一共展示了Table::hasColumn方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testDropColumn

 public function testDropColumn()
 {
     $type = Type::getType('integer');
     $columns = array();
     $columns[] = new Column("foo", $type);
     $columns[] = new Column("bar", $type);
     $table = new Table("foo", $columns, array(), array());
     $this->assertTrue($table->hasColumn("foo"));
     $this->assertTrue($table->hasColumn("bar"));
     $table->dropColumn("foo")->dropColumn("bar");
     $this->assertFalse($table->hasColumn("foo"));
     $this->assertFalse($table->hasColumn("bar"));
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:13,代码来源:TableTest.php

示例2: addColumns

 /**
  * Adds the missing columns to the table
  *
  * @param \Doctrine\DBAL\Schema\Table $table Table object
  * @return \Doctrine\DBAL\Schema\Table Updated table object
  */
 protected function addColumns(\Doctrine\DBAL\Schema\Table $table)
 {
     $columns = array('company' => array('string', array('length' => 100)), 'vatid' => array('string', array('length' => 32)), 'salutation' => array('string', array('length' => 8)), 'title' => array('string', array('length' => 64)), 'firstname' => array('string', array('length' => 64)), 'lastname' => array('string', array('length' => 64)), 'address1' => array('string', array('length' => 255)), 'address2' => array('string', array('length' => 255)), 'address3' => array('string', array('length' => 255)), 'postal' => array('string', array('length' => 16)), 'city' => array('string', array('length' => 255)), 'state' => array('string', array('length' => 255)), 'langid' => array('string', array('length' => 5, 'notnull' => false)), 'countryid' => array('string', array('length' => 2, 'notnull' => false, 'fixed' => true)), 'telephone' => array('string', array('length' => 32)), 'telefax' => array('string', array('length' => 32)), 'website' => array('string', array('length' => 255)), 'birthday' => array('date', array('notnull' => false)), 'vdate' => array('date', array('notnull' => false)), 'status' => array('smallint', array()), 'mtime' => array('datetime', array()), 'ctime' => array('datetime', array()), 'editor' => array('string', array('length' => 255)));
     foreach ($columns as $name => $def) {
         if ($table->hasColumn($name) === false) {
             $table->addColumn($name, $def[0], $def[1]);
         }
     }
     return $table;
 }
开发者ID:aimeos,项目名称:ai-ezpublish,代码行数:16,代码来源:EzuserAddAddress.php

示例3: addColumns

 /**
  * Adds the missing columns to the table
  *
  * @param \Doctrine\DBAL\Schema\Table $table Table object
  * @return \Doctrine\DBAL\Schema\Table Updated table object
  */
 protected function addColumns(\Doctrine\DBAL\Schema\Table $table)
 {
     $columns = array('cdate' => array('string', array('fixed' => 10)), 'cmonth' => array('string', array('fixed' => 7)), 'cweek' => array('string', array('fixed' => 7)), 'chour' => array('string', array('fixed' => 2)));
     foreach ($columns as $name => $def) {
         if ($table->hasColumn($name) === false) {
             $table->addColumn($name, $def[0], $def[1]);
         }
     }
     return $table;
 }
开发者ID:nos3,项目名称:aimeos-core,代码行数:16,代码来源:OrderAddTimes.php

示例4: checkColumnExists

 /**
  * Determine if a column already exists.
  *
  * @param string $column
  * @param bool   $throwException
  *
  * @return bool
  *
  * @throws SchemaException
  */
 public function checkColumnExists($column, $throwException = false)
 {
     //check to ensure column doesn't exist
     if ($this->toTable->hasColumn($column)) {
         if ($throwException) {
             throw new SchemaException("The column {$column} already exists in {$this->tableName}");
         }
         return true;
     }
     return false;
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:21,代码来源:ColumnSchemaHelper.php

示例5: _gatherRelationJoinColumns

 /**
  * Gather columns and fk constraints that are required for one part of relationship.
  *
  * @param array $joinColumns
  * @param \Doctrine\DBAL\Schema\Table $theJoinTable
  * @param ClassMetadata $class
  * @param array $mapping
  * @param array $primaryKeyColumns
  * @param array $uniqueConstraints
  */
 private function _gatherRelationJoinColumns($joinColumns, $theJoinTable, $class, $mapping, &$primaryKeyColumns, &$uniqueConstraints)
 {
     $localColumns = array();
     $foreignColumns = array();
     $fkOptions = array();
     $foreignTableName = $this->quoteStrategy->getTableName($class, $this->platform);
     foreach ($joinColumns as $joinColumn) {
         list($definingClass, $referencedFieldName) = $this->getDefiningClass($class, $joinColumn['referencedColumnName']);
         if (!$definingClass) {
             throw new \Doctrine\ORM\ORMException("Column name `" . $joinColumn['referencedColumnName'] . "` referenced for relation from " . $mapping['sourceEntity'] . " towards " . $mapping['targetEntity'] . " does not exist.");
         }
         $quotedColumnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform);
         $quotedRefColumnName = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $class, $this->platform);
         $primaryKeyColumns[] = $quotedColumnName;
         $localColumns[] = $quotedColumnName;
         $foreignColumns[] = $quotedRefColumnName;
         if (!$theJoinTable->hasColumn($quotedColumnName)) {
             // Only add the column to the table if it does not exist already.
             // It might exist already if the foreign key is mapped into a regular
             // property as well.
             $fieldMapping = $definingClass->getFieldMapping($referencedFieldName);
             $columnDef = null;
             if (isset($joinColumn['columnDefinition'])) {
                 $columnDef = $joinColumn['columnDefinition'];
             } else {
                 if (isset($fieldMapping['columnDefinition'])) {
                     $columnDef = $fieldMapping['columnDefinition'];
                 }
             }
             $columnOptions = array('notnull' => false, 'columnDefinition' => $columnDef);
             if (isset($joinColumn['nullable'])) {
                 $columnOptions['notnull'] = !$joinColumn['nullable'];
             }
             if (isset($fieldMapping['options'])) {
                 $columnOptions['options'] = $fieldMapping['options'];
             }
             if ($fieldMapping['type'] == "string" && isset($fieldMapping['length'])) {
                 $columnOptions['length'] = $fieldMapping['length'];
             } else {
                 if ($fieldMapping['type'] == "decimal") {
                     $columnOptions['scale'] = $fieldMapping['scale'];
                     $columnOptions['precision'] = $fieldMapping['precision'];
                 }
             }
             $theJoinTable->addColumn($quotedColumnName, $fieldMapping['type'], $columnOptions);
         }
         if (isset($joinColumn['unique']) && $joinColumn['unique'] == true) {
             $uniqueConstraints[] = array('columns' => array($quotedColumnName));
         }
         if (isset($joinColumn['onDelete'])) {
             $fkOptions['onDelete'] = $joinColumn['onDelete'];
         }
     }
     $theJoinTable->addUnnamedForeignKeyConstraint($foreignTableName, $localColumns, $foreignColumns, $fkOptions);
 }
开发者ID:Herriniaina,项目名称:iVarotra,代码行数:65,代码来源:SchemaTool.php

示例6: addNamedForeignKeyConstraint

 /**
  * Add a foreign key constraint with a given name
  *
  * @param string $name
  * @param Table $foreignTable
  * @param array $localColumns
  * @param array $foreignColumns
  * @param array $options
  * @return Table
  */
 public function addNamedForeignKeyConstraint($name, $foreignTable, array $localColumnNames, array $foreignColumnNames, array $options = array())
 {
     if ($foreignTable instanceof Table) {
         $foreignTableName = $foreignTable->getName();
         foreach ($foreignColumnNames as $columnName) {
             if (!$foreignTable->hasColumn($columnName)) {
                 throw SchemaException::columnDoesNotExist($columnName, $foreignTable->getName());
             }
         }
     } else {
         $foreignTableName = $foreignTable;
     }
     foreach ($localColumnNames as $columnName) {
         if (!$this->hasColumn($columnName)) {
             throw SchemaException::columnDoesNotExist($columnName, $this->_name);
         }
     }
     $constraint = new ForeignKeyConstraint($localColumnNames, $foreignTableName, $foreignColumnNames, $name, $options);
     $this->_addForeignKeyConstraint($constraint);
     return $this;
 }
开发者ID:michaelnavarro,项目名称:zc,代码行数:31,代码来源:Table.php

示例7: _gatherRelationJoinColumns

 /**
  * Gather columns and fk constraints that are required for one part of relationship.
  * 
  * @param array $joinColumns
  * @param \Doctrine\DBAL\Schema\Table $theJoinTable
  * @param ClassMetadata $class
  * @param \Doctrine\ORM\Mapping\AssociationMapping $mapping
  * @param array $primaryKeyColumns
  * @param array $uniqueConstraints
  */
 private function _gatherRelationJoinColumns($joinColumns, $theJoinTable, $class, $mapping, &$primaryKeyColumns, &$uniqueConstraints)
 {
     $localColumns = array();
     $foreignColumns = array();
     $fkOptions = array();
     foreach ($joinColumns as $joinColumn) {
         // Note that this thing might be quoted, i.e. `foo`, [foo], ...
         $columnName = $mapping->getQuotedJoinColumnName($joinColumn['name'], $this->_platform);
         $referencedFieldName = $class->getFieldName($joinColumn['referencedColumnName']);
         if (!$class->hasField($referencedFieldName)) {
             throw new \Doctrine\Common\DoctrineException("Column name `" . $joinColumn['referencedColumnName'] . "` referenced for relation from " . "{$mapping->sourceEntityName} towards {$mapping->targetEntityName} does not exist.");
         }
         $primaryKeyColumns[] = $columnName;
         $localColumns[] = $columnName;
         $foreignColumns[] = $joinColumn['referencedColumnName'];
         if (!$theJoinTable->hasColumn($joinColumn['name'])) {
             // Only add the column to the table if it does not exist already.
             // It might exist already if the foreign key is mapped into a regular
             // property as well.
             $fieldMapping = $class->getFieldMapping($referencedFieldName);
             $columnDef = null;
             if (isset($joinColumn['columnDefinition'])) {
                 $columnDef = $joinColumn['columnDefinition'];
             } else {
                 if (isset($fieldMapping['columnDefinition'])) {
                     $columnDef = $fieldMapping['columnDefinition'];
                 }
             }
             $columnOptions = array('notnull' => false, 'columnDefinition' => $columnDef);
             if (isset($joinColumn['nullable'])) {
                 $columnOptions['notnull'] = !$joinColumn['nullable'];
             }
             $theJoinTable->createColumn($columnName, $class->getTypeOfColumn($joinColumn['referencedColumnName']), $columnOptions);
         }
         if (isset($joinColumn['unique']) && $joinColumn['unique'] == true) {
             $uniqueConstraints[] = array('columns' => array($columnName));
         }
         if (isset($joinColumn['onUpdate'])) {
             $fkOptions['onUpdate'] = $joinColumn['onUpdate'];
         }
         if (isset($joinColumn['onDelete'])) {
             $fkOptions['onDelete'] = $joinColumn['onDelete'];
         }
     }
     $theJoinTable->addUnnamedForeignKeyConstraint($class->getQuotedTableName($this->_platform), $localColumns, $foreignColumns, $fkOptions);
 }
开发者ID:nvdnkpr,项目名称:symfony-demo,代码行数:56,代码来源:SchemaTool.php

示例8: diffTable

 /**
  * Returns the difference between the tables $table1 and $table2.
  *
  * If there are no differences this method returns the boolean false.
  *
  * @param \Doctrine\DBAL\Schema\Table $table1
  * @param \Doctrine\DBAL\Schema\Table $table2
  *
  * @return boolean|\Doctrine\DBAL\Schema\TableDiff
  */
 public function diffTable(Table $table1, Table $table2)
 {
     $changes = 0;
     $tableDifferences = new TableDiff($table1->getName());
     $tableDifferences->fromTable = $table1;
     $table1Columns = $table1->getColumns();
     $table2Columns = $table2->getColumns();
     /* See if all the fields in table 1 exist in table 2 */
     foreach ($table2Columns as $columnName => $column) {
         if (!$table1->hasColumn($columnName)) {
             $tableDifferences->addedColumns[$columnName] = $column;
             $changes++;
         }
     }
     /* See if there are any removed fields in table 2 */
     foreach ($table1Columns as $columnName => $column) {
         // See if column is removed in table 2.
         if (!$table2->hasColumn($columnName)) {
             $tableDifferences->removedColumns[$columnName] = $column;
             $changes++;
             continue;
         }
         // See if column has changed properties in table 2.
         $changedProperties = $this->diffColumn($column, $table2->getColumn($columnName));
         if (!empty($changedProperties)) {
             $columnDiff = new ColumnDiff($column->getName(), $table2->getColumn($columnName), $changedProperties);
             $columnDiff->fromColumn = $column;
             $tableDifferences->changedColumns[$column->getName()] = $columnDiff;
             $changes++;
         }
     }
     // #BUG-2317 Avoid column renaming when both enable and disable different modules
     // $this->detectColumnRenamings($tableDifferences);
     $table1Indexes = $table1->getIndexes();
     $table2Indexes = $table2->getIndexes();
     foreach ($table2Indexes as $index2Name => $index2Definition) {
         foreach ($table1Indexes as $index1Name => $index1Definition) {
             if ($this->diffIndex($index1Definition, $index2Definition) === false) {
                 /*if ( ! $index1Definition->isPrimary() && $index1Name != $index2Name) {
                       $tableDifferences->renamedIndexes[$index1Name] = $index2Definition;
                       $changes++;
                   }*/
                 unset($table1Indexes[$index1Name]);
                 unset($table2Indexes[$index2Name]);
             } else {
                 if ($index1Name == $index2Name) {
                     $tableDifferences->changedIndexes[$index2Name] = $table2Indexes[$index2Name];
                     unset($table1Indexes[$index1Name]);
                     unset($table2Indexes[$index2Name]);
                     $changes++;
                 }
             }
         }
     }
     foreach ($table1Indexes as $index1Name => $index1Definition) {
         $tableDifferences->removedIndexes[$index1Name] = $index1Definition;
         $changes++;
     }
     foreach ($table2Indexes as $index2Name => $index2Definition) {
         $tableDifferences->addedIndexes[$index2Name] = $index2Definition;
         $changes++;
     }
     $fromFkeys = $table1->getForeignKeys();
     $toFkeys = $table2->getForeignKeys();
     foreach ($fromFkeys as $key1 => $constraint1) {
         foreach ($toFkeys as $key2 => $constraint2) {
             if ($this->diffForeignKey($constraint1, $constraint2) === false) {
                 unset($fromFkeys[$key1]);
                 unset($toFkeys[$key2]);
             } else {
                 if (strtolower($constraint1->getName()) == strtolower($constraint2->getName())) {
                     $tableDifferences->changedForeignKeys[] = $constraint2;
                     $changes++;
                     unset($fromFkeys[$key1]);
                     unset($toFkeys[$key2]);
                 }
             }
         }
     }
     foreach ($fromFkeys as $constraint1) {
         $tableDifferences->removedForeignKeys[] = $constraint1;
         $changes++;
     }
     foreach ($toFkeys as $constraint2) {
         $tableDifferences->addedForeignKeys[] = $constraint2;
         $changes++;
     }
     return $changes ? $tableDifferences : false;
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:99,代码来源:Comparator.php

示例9: gatherRelationJoinColumns

 /**
  * Gathers columns and fk constraints that are required for one part of relationship.
  *
  * @param array         $joinColumns
  * @param Table         $theJoinTable
  * @param ClassMetadata $class
  * @param array         $mapping
  * @param array         $primaryKeyColumns
  * @param array         $addedFks
  * @param array         $blacklistedFks
  *
  * @return void
  *
  * @throws \Doctrine\ORM\ORMException
  */
 private function gatherRelationJoinColumns($joinColumns, $theJoinTable, $class, $mapping, &$primaryKeyColumns, &$addedFks, &$blacklistedFks)
 {
     $localColumns = array();
     $foreignColumns = array();
     $fkOptions = array();
     $foreignTableName = $this->quoteStrategy->getTableName($class, $this->platform);
     $uniqueConstraints = array();
     foreach ($joinColumns as $joinColumn) {
         list($definingClass, $referencedFieldName) = $this->getDefiningClass($class, $joinColumn['referencedColumnName']);
         if (!$definingClass) {
             throw new \Doctrine\ORM\ORMException("Column name `" . $joinColumn['referencedColumnName'] . "` referenced for relation from " . $mapping['sourceEntity'] . " towards " . $mapping['targetEntity'] . " does not exist.");
         }
         $quotedColumnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform);
         $quotedRefColumnName = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $class, $this->platform);
         $primaryKeyColumns[] = $quotedColumnName;
         $localColumns[] = $quotedColumnName;
         $foreignColumns[] = $quotedRefColumnName;
         if (!$theJoinTable->hasColumn($quotedColumnName)) {
             // Only add the column to the table if it does not exist already.
             // It might exist already if the foreign key is mapped into a regular
             // property as well.
             $fieldMapping = $definingClass->getFieldMapping($referencedFieldName);
             $columnDef = null;
             if (isset($joinColumn['columnDefinition'])) {
                 $columnDef = $joinColumn['columnDefinition'];
             } elseif (isset($fieldMapping['columnDefinition'])) {
                 $columnDef = $fieldMapping['columnDefinition'];
             }
             $columnOptions = array('notnull' => false, 'columnDefinition' => $columnDef);
             if (isset($joinColumn['nullable'])) {
                 $columnOptions['notnull'] = !$joinColumn['nullable'];
             }
             if (isset($fieldMapping['options'])) {
                 $columnOptions['options'] = $fieldMapping['options'];
             }
             if ($fieldMapping['type'] == "string" && isset($fieldMapping['length'])) {
                 $columnOptions['length'] = $fieldMapping['length'];
             } elseif ($fieldMapping['type'] == "decimal") {
                 $columnOptions['scale'] = $fieldMapping['scale'];
                 $columnOptions['precision'] = $fieldMapping['precision'];
             }
             $theJoinTable->addColumn($quotedColumnName, $fieldMapping['type'], $columnOptions);
         }
         if (isset($joinColumn['unique']) && $joinColumn['unique'] == true) {
             $uniqueConstraints[] = array('columns' => array($quotedColumnName));
         }
         if (isset($joinColumn['onDelete'])) {
             $fkOptions['onDelete'] = $joinColumn['onDelete'];
         }
     }
     // Prefer unique constraints over implicit simple indexes created for foreign keys.
     // Also avoids index duplication.
     foreach ($uniqueConstraints as $indexName => $unique) {
         $theJoinTable->addUniqueIndex($unique['columns'], is_numeric($indexName) ? null : $indexName);
     }
     $compositeName = $theJoinTable->getName() . '.' . implode('', $localColumns);
     if (isset($addedFks[$compositeName]) && ($foreignTableName != $addedFks[$compositeName]['foreignTableName'] || 0 < count(array_diff($foreignColumns, $addedFks[$compositeName]['foreignColumns'])))) {
         foreach ($theJoinTable->getForeignKeys() as $fkName => $key) {
             if (0 === count(array_diff($key->getLocalColumns(), $localColumns)) && ($key->getForeignTableName() != $foreignTableName || 0 < count(array_diff($key->getForeignColumns(), $foreignColumns)))) {
                 $theJoinTable->removeForeignKey($fkName);
                 break;
             }
         }
         $blacklistedFks[$compositeName] = true;
     } elseif (!isset($blacklistedFks[$compositeName])) {
         $addedFks[$compositeName] = array('foreignTableName' => $foreignTableName, 'foreignColumns' => $foreignColumns);
         $theJoinTable->addUnnamedForeignKeyConstraint($foreignTableName, $localColumns, $foreignColumns, $fkOptions);
     }
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:84,代码来源:SchemaTool.php

示例10: renameManyToOneExtendField

 protected function renameManyToOneExtendField(Schema $schema, QueryBag $queries, Table $table, $associationName)
 {
     $oldColumnName = 'field_' . $associationName . '_id';
     if ($table->hasColumn($oldColumnName)) {
         $newColumnName = $this->nameGenerator->generateManyToOneRelationColumnName($associationName);
         $this->renameExtension->renameColumn($schema, $queries, $table, $oldColumnName, $newColumnName);
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:8,代码来源:RenameExtendTablesAndColumns.php

示例11: diffTable

 /**
  * Returns the difference between the tables $table1 and $table2.
  *
  * If there are no differences this method returns the boolean false.
  *
  * @param \Doctrine\DBAL\Schema\Table $table1
  * @param \Doctrine\DBAL\Schema\Table $table2
  *
  * @return boolean|\Doctrine\DBAL\Schema\TableDiff
  */
 public function diffTable(Table $table1, Table $table2)
 {
     $changes = 0;
     $tableDifferences = new TableDiff($table1->getName());
     $tableDifferences->fromTable = $table1;
     $table1Columns = $table1->getColumns();
     $table2Columns = $table2->getColumns();
     /* See if all the fields in table 1 exist in table 2 */
     foreach ($table2Columns as $columnName => $column) {
         if (!$table1->hasColumn($columnName)) {
             $tableDifferences->addedColumns[$columnName] = $column;
             $changes++;
         }
     }
     /* See if there are any removed fields in table 2 */
     foreach ($table1Columns as $columnName => $column) {
         // See if column is removed in table 2.
         if (!$table2->hasColumn($columnName)) {
             $tableDifferences->removedColumns[$columnName] = $column;
             $changes++;
             continue;
         }
         // See if column has changed properties in table 2.
         $changedProperties = $this->diffColumn($column, $table2->getColumn($columnName));
         if (!empty($changedProperties)) {
             $columnDiff = new ColumnDiff($column->getName(), $table2->getColumn($columnName), $changedProperties);
             $columnDiff->fromColumn = $column;
             $tableDifferences->changedColumns[$column->getName()] = $columnDiff;
             $changes++;
         }
     }
     $this->detectColumnRenamings($tableDifferences);
     $table1Indexes = $table1->getIndexes();
     $table2Indexes = $table2->getIndexes();
     /* See if all the indexes in table 1 exist in table 2 */
     foreach ($table2Indexes as $indexName => $index) {
         if ($index->isPrimary() && $table1->hasPrimaryKey() || $table1->hasIndex($indexName)) {
             continue;
         }
         $tableDifferences->addedIndexes[$indexName] = $index;
         $changes++;
     }
     /* See if there are any removed indexes in table 2 */
     foreach ($table1Indexes as $indexName => $index) {
         // See if index is removed in table 2.
         if ($index->isPrimary() && !$table2->hasPrimaryKey() || !$index->isPrimary() && !$table2->hasIndex($indexName)) {
             $tableDifferences->removedIndexes[$indexName] = $index;
             $changes++;
             continue;
         }
         // See if index has changed in table 2.
         $table2Index = $index->isPrimary() ? $table2->getPrimaryKey() : $table2->getIndex($indexName);
         if ($this->diffIndex($index, $table2Index)) {
             $tableDifferences->changedIndexes[$indexName] = $table2Index;
             $changes++;
         }
     }
     $this->detectIndexRenamings($tableDifferences);
     $fromFkeys = $table1->getForeignKeys();
     $toFkeys = $table2->getForeignKeys();
     foreach ($fromFkeys as $key1 => $constraint1) {
         foreach ($toFkeys as $key2 => $constraint2) {
             if ($this->diffForeignKey($constraint1, $constraint2) === false) {
                 unset($fromFkeys[$key1]);
                 unset($toFkeys[$key2]);
             } else {
                 if (strtolower($constraint1->getName()) == strtolower($constraint2->getName())) {
                     $tableDifferences->changedForeignKeys[] = $constraint2;
                     $changes++;
                     unset($fromFkeys[$key1]);
                     unset($toFkeys[$key2]);
                 }
             }
         }
     }
     foreach ($fromFkeys as $constraint1) {
         $tableDifferences->removedForeignKeys[] = $constraint1;
         $changes++;
     }
     foreach ($toFkeys as $constraint2) {
         $tableDifferences->addedForeignKeys[] = $constraint2;
         $changes++;
     }
     return $changes ? $tableDifferences : false;
 }
开发者ID:alvarobfdev,项目名称:applog,代码行数:95,代码来源:Comparator.php

示例12: testNormalizesColumnNames

 /**
  * @dataProvider getNormalizesAssetNames
  * @group DBAL-831
  */
 public function testNormalizesColumnNames($assetName)
 {
     $table = new Table('test');
     $table->addColumn($assetName, 'integer');
     $table->addIndex(array($assetName), $assetName);
     $table->addForeignKeyConstraint('test', array($assetName), array($assetName), array(), $assetName);
     $this->assertTrue($table->hasColumn($assetName));
     $this->assertTrue($table->hasColumn('foo'));
     $this->assertInstanceOf('Doctrine\\DBAL\\Schema\\Column', $table->getColumn($assetName));
     $this->assertInstanceOf('Doctrine\\DBAL\\Schema\\Column', $table->getColumn('foo'));
     $this->assertTrue($table->hasIndex($assetName));
     $this->assertTrue($table->hasIndex('foo'));
     $this->assertInstanceOf('Doctrine\\DBAL\\Schema\\Index', $table->getIndex($assetName));
     $this->assertInstanceOf('Doctrine\\DBAL\\Schema\\Index', $table->getIndex('foo'));
     $this->assertTrue($table->hasForeignKey($assetName));
     $this->assertTrue($table->hasForeignKey('foo'));
     $this->assertInstanceOf('Doctrine\\DBAL\\Schema\\ForeignKeyConstraint', $table->getForeignKey($assetName));
     $this->assertInstanceOf('Doctrine\\DBAL\\Schema\\ForeignKeyConstraint', $table->getForeignKey('foo'));
     $table->renameIndex($assetName, $assetName);
     $this->assertTrue($table->hasIndex($assetName));
     $this->assertTrue($table->hasIndex('foo'));
     $table->renameIndex($assetName, 'foo');
     $this->assertTrue($table->hasIndex($assetName));
     $this->assertTrue($table->hasIndex('foo'));
     $table->renameIndex('foo', $assetName);
     $this->assertTrue($table->hasIndex($assetName));
     $this->assertTrue($table->hasIndex('foo'));
     $table->renameIndex($assetName, 'bar');
     $this->assertFalse($table->hasIndex($assetName));
     $this->assertFalse($table->hasIndex('foo'));
     $this->assertTrue($table->hasIndex('bar'));
     $table->renameIndex('bar', $assetName);
     $table->dropColumn($assetName);
     $table->dropIndex($assetName);
     $table->removeForeignKey($assetName);
     $this->assertFalse($table->hasColumn($assetName));
     $this->assertFalse($table->hasColumn('foo'));
     $this->assertFalse($table->hasIndex($assetName));
     $this->assertFalse($table->hasIndex('foo'));
     $this->assertFalse($table->hasForeignKey($assetName));
     $this->assertFalse($table->hasForeignKey('foo'));
 }
开发者ID:selimcr,项目名称:servigases,代码行数:46,代码来源:TableTest.php

示例13: exists

 /**
  * Test that a column exists.
  *
  * @return $this
  */
 public function exists()
 {
     $this->assertTrue($this->table->hasColumn($this->name), "The table column `{$this->name}` does not exist.");
     return $this;
 }
开发者ID:erikgall,项目名称:eloquent-phpunit,代码行数:10,代码来源:Column.php

示例14: createSqlData

 /**
  * Creates the sqlite unit test database
  */
 public function createSqlData()
 {
     $dataDir = __DIR__ . '/tests/unit/ORM/data';
     $database = $dataDir . '/original/sqlite.test.db';
     $this->say('Creating test database in ' . $database);
     if (file_exists($database)) {
         $this->say('Removing old test database');
         $this->_remove($database);
     }
     $connection = DriverManager::getConnection(['url' => 'sqlite:///' . $database]);
     $files = glob($dataDir . '/original/*.csv');
     foreach ($files as $file) {
         $tableName = basename($file, '.csv');
         $table = new Table($tableName);
         $records = $this->loadData($file);
         $columns = array_keys(reset($records));
         foreach ($columns as $column) {
             $type = preg_match('~\\bid$~i', $column) ? 'integer' : 'string';
             $table->addColumn($column, $type, ['Notnull' => false]);
         }
         if ($table->hasColumn('id')) {
             $table->setPrimaryKey(['id']);
         }
         $this->say('Creating table ' . $tableName);
         $connection->getSchemaManager()->createTable($table);
         $this->say('Adding ' . count($records) . ' records');
         foreach ($records as $record) {
             $connection->insert($tableName, $record);
         }
     }
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:34,代码来源:RoboFile.php


注:本文中的Doctrine\DBAL\Schema\Table::hasColumn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。