當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Column::toArray方法代碼示例

本文整理匯總了PHP中Doctrine\DBAL\Schema\Column::toArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP Column::toArray方法的具體用法?PHP Column::toArray怎麽用?PHP Column::toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\DBAL\Schema\Column的用法示例。


在下文中一共展示了Column::toArray方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createColumnReplacement

 /**
  * Creates a column replacement, which has a quoted name.
  *
  * @param Column $column
  *
  * @return Column
  */
 private function createColumnReplacement(Column $column)
 {
     $columnConfig = $column->toArray();
     $columnConfig['platformOptions'] = $column->getPlatformOptions();
     $columnConfig['customSchemaOptions'] = $column->getCustomSchemaOptions();
     return new Column($this->platform->quoteIdentifier($column->getName()), $column->getType(), $columnConfig);
 }
開發者ID:digilist,項目名稱:snakedumper,代碼行數:14,代碼來源:IdentifierQuoter.php

示例2: testColumnComment

 /**
  * @group DBAL-42
  */
 public function testColumnComment()
 {
     $column = new Column("bar", Type::getType('string'));
     $this->assertNull($column->getComment());
     $column->setComment("foo");
     $this->assertEquals("foo", $column->getComment());
     $columnArray = $column->toArray();
     $this->assertArrayHasKey('comment', $columnArray);
     $this->assertEquals('foo', $columnArray['comment']);
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:13,代碼來源:ColumnTest.php

示例3: __construct

 /**
  * Maps only needed definitions defined as __CLASS__ properties
  * @param Column $column
  */
 public function __construct(Column $column)
 {
     foreach ($column->toArray() as $type => $value) {
         if (array_key_exists($type, get_class_vars(__CLASS__))) {
             if ($value instanceof Type) {
                 $this->{$type} = $value->getName();
                 continue;
             }
             $this->{$type} = $value;
         }
     }
     return $this;
 }
開發者ID:derduesseldorf,項目名稱:formbuilder,代碼行數:17,代碼來源:FormSchema.php

示例4: getAlterTableAddColumnClause

 /**
  * Returns the SQL clause for creating a column in a table alteration.
  *
  * @param Column $column The column to add.
  *
  * @return string
  */
 protected function getAlterTableAddColumnClause(Column $column)
 {
     return 'ADD ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
 }
開發者ID:Kevin-ZK,項目名稱:vaneDisk,代碼行數:11,代碼來源:SQLAnywherePlatform.php

示例5: setRenamedColumns

 /**
  * Set the renamed columns on the table diff.
  *
  * @param  \Doctrine\DBAL\Schema\TableDiff  $tableDiff
  * @param  \Illuminate\Support\Fluent  $command
  * @param  \Doctrine\DBAL\Schema\Column  $column
  * @return \Doctrine\DBAL\Schema\TableDiff
  */
 protected function setRenamedColumns(TableDiff $tableDiff, Fluent $command, Column $column)
 {
     $newColumn = new Column($command->to, $column->getType(), $column->toArray());
     $tableDiff->renamedColumns = array($command->from => $newColumn);
     return $tableDiff;
 }
開發者ID:GeorgeBroadley,項目名稱:caffeine-vendor,代碼行數:14,代碼來源:Grammar.php

示例6: getAlterTableAddDefaultConstraintClause

 /**
  * Returns the SQL clause for adding a default constraint in an ALTER TABLE statement.
  *
  * @param  string $tableName The name of the table to generate the clause for.
  * @param  Column $column    The column to generate the clause for.
  *
  * @return string
  */
 private function getAlterTableAddDefaultConstraintClause($tableName, Column $column)
 {
     $columnDef = $column->toArray();
     $columnDef['name'] = $column->getQuotedName($this);
     return 'ADD' . $this->getDefaultConstraintDeclarationSQL($tableName, $columnDef);
 }
開發者ID:aleguisf,項目名稱:fvdev1,代碼行數:14,代碼來源:SQLServerPlatform.php

示例7: diffColumn

 /**
  * Returns the difference between the fields $field1 and $field2.
  *
  * If there are differences this method returns $field2, otherwise the
  * boolean false.
  *
  * @param \Doctrine\DBAL\Schema\Column $column1
  * @param \Doctrine\DBAL\Schema\Column $column2
  *
  * @return array
  */
 public function diffColumn(Column $column1, Column $column2)
 {
     $properties1 = $column1->toArray();
     $properties2 = $column2->toArray();
     $changedProperties = array();
     foreach (array('type', 'notnull', 'unsigned', 'autoincrement') as $property) {
         if ($properties1[$property] != $properties2[$property]) {
             $changedProperties[] = $property;
         }
     }
     if ($properties1['default'] != $properties2['default'] || null === $properties1['default'] && null !== $properties2['default'] || null === $properties2['default'] && null !== $properties1['default']) {
         $changedProperties[] = 'default';
     }
     if ($properties1['type'] instanceof Types\StringType && !$properties1['type'] instanceof Types\GuidType || $properties1['type'] instanceof Types\BinaryType) {
         // check if value of length is set at all, default value assumed otherwise.
         $length1 = $properties1['length'] ?: 255;
         $length2 = $properties2['length'] ?: 255;
         if ($length1 != $length2) {
             $changedProperties[] = 'length';
         }
         if ($properties1['fixed'] != $properties2['fixed']) {
             $changedProperties[] = 'fixed';
         }
     } elseif ($properties1['type'] instanceof Types\DecimalType) {
         if (($properties1['precision'] ?: 10) != ($properties2['precision'] ?: 10)) {
             $changedProperties[] = 'precision';
         }
         if ($properties1['scale'] != $properties2['scale']) {
             $changedProperties[] = 'scale';
         }
     }
     // A null value and an empty string are actually equal for a comment so they should not trigger a change.
     if ($properties1['comment'] !== $properties2['comment'] && !(null === $properties1['comment'] && '' === $properties2['comment']) && !(null === $properties2['comment'] && '' === $properties1['comment'])) {
         $changedProperties[] = 'comment';
     }
     $customOptions1 = $column1->getCustomSchemaOptions();
     $customOptions2 = $column2->getCustomSchemaOptions();
     // Remove option-as-object
     foreach ($customOptions2 as $k => $v) {
         if (is_object($v)) {
             unset($customOptions2[$k]);
         }
     }
     foreach (array_merge(array_keys($customOptions1), array_keys($customOptions2)) as $key) {
         if (!array_key_exists($key, $properties1) || !array_key_exists($key, $properties2)) {
             $changedProperties[] = $key;
         } elseif ($properties1[$key] !== $properties2[$key]) {
             $changedProperties[] = $key;
         }
     }
     $platformOptions1 = $column1->getPlatformOptions();
     $platformOptions2 = $column2->getPlatformOptions();
     foreach (array_keys(array_intersect_key($platformOptions1, $platformOptions2)) as $key) {
         if ($properties1[$key] !== $properties2[$key]) {
             $changedProperties[] = $key;
         }
     }
     return array_unique($changedProperties);
 }
開發者ID:kirkbauer2,項目名稱:kirkxc,代碼行數:70,代碼來源:Comparator.php

示例8: diffColumn

 /**
  * Returns the difference between the fields $field1 and $field2.
  *
  * If there are differences this method returns $field2, otherwise the
  * boolean false.
  *
  * @param \Doctrine\DBAL\Schema\Column $column1
  * @param \Doctrine\DBAL\Schema\Column $column2
  *
  * @return array
  */
 public function diffColumn(Column $column1, Column $column2)
 {
     $properties1 = $column1->toArray();
     $properties2 = $column2->toArray();
     $changedProperties = array();
     foreach (array('type', 'notnull', 'unsigned', 'autoincrement') as $property) {
         if ($properties1[$property] != $properties2[$property]) {
             $changedProperties[] = $property;
         }
     }
     if ($properties1['default'] != $properties2['default'] || null === $properties1['default'] && null !== $properties2['default'] || null === $properties2['default'] && null !== $properties1['default']) {
         $changedProperties[] = 'default';
     }
     if ($properties1['type'] instanceof Types\StringType || $properties1['type'] instanceof Types\BinaryType) {
         // check if value of length is set at all, default value assumed otherwise.
         $length1 = $properties1['length'] ?: 255;
         $length2 = $properties2['length'] ?: 255;
         if ($length1 != $length2) {
             $changedProperties[] = 'length';
         }
         if ($properties1['fixed'] != $properties2['fixed']) {
             $changedProperties[] = 'fixed';
         }
     } elseif ($properties1['type'] instanceof Types\DecimalType) {
         if (($properties1['precision'] ?: 10) != ($properties2['precision'] ?: 10)) {
             $changedProperties[] = 'precision';
         }
         if ($properties1['scale'] != $properties2['scale']) {
             $changedProperties[] = 'scale';
         }
     }
     // only allow to delete comment if its set to '' not to null.
     if ($properties1['comment'] !== null && $properties1['comment'] != $properties2['comment']) {
         $changedProperties[] = 'comment';
     }
     $customOptions1 = $column1->getCustomSchemaOptions();
     $customOptions2 = $column2->getCustomSchemaOptions();
     foreach (array_merge(array_keys($customOptions1), array_keys($customOptions2)) as $key) {
         if (!array_key_exists($key, $properties1) || !array_key_exists($key, $properties2)) {
             $changedProperties[] = $key;
         } elseif ($properties1[$key] !== $properties2[$key]) {
             $changedProperties[] = $key;
         }
     }
     $platformOptions1 = $column1->getPlatformOptions();
     $platformOptions2 = $column2->getPlatformOptions();
     foreach (array_keys(array_intersect_key($platformOptions1, $platformOptions2)) as $key) {
         if ($properties1[$key] !== $properties2[$key]) {
             $changedProperties[] = $key;
         }
     }
     return array_unique($changedProperties);
 }
開發者ID:hilmysyarif,項目名稱:l4-bootstrap-admin,代碼行數:64,代碼來源:Comparator.php

示例9: acceptColumn

 /**
  * Accept a column in a table
  *
  * @param Table  $table  a table object
  * @param Column $column a column object
  * 
  * @return void
  */
 public function acceptColumn(Table $table, Column $column)
 {
     $this->schemaArray['tables'][$table->getName()]['columns'][$column->getName()] = $column->toArray();
     $this->schemaArray['tables'][$table->getName()]['columns'][$column->getName()]['type'] = $column->getType()->getName();
 }
開發者ID:ming-hai,項目名稱:XoopsCore,代碼行數:13,代碼來源:ExportVisitor.php


注:本文中的Doctrine\DBAL\Schema\Column::toArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。