• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Schema\Column类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: mapForeignKeys

 public function mapForeignKeys($table, Column $column, $id = null)
 {
     try {
         $relatedRows = $this->db->executeQuery("SELECT * FROM {$table} ORDER BY id ASC")->fetchAll();
         if (isset($relatedRows[0]['name'])) {
             $foreign = 'name';
         } else {
             $comments = json_decode($column->getComment(), true);
             if (!empty($comments) && is_array($comments)) {
                 $foreign = $foreign['foreign'];
             } else {
                 $foreign = 'id';
             }
         }
         $choices = array();
         foreach ($relatedRows as $relatedRow) {
             if (null !== $id && $relatedRow['id'] == $id) {
                 return $relatedRow[$foreign];
             }
             $choices[$relatedRow['id']] = $relatedRow[$foreign];
         }
         return $choices;
     } catch (\Exception $e) {
         return false;
     }
 }
开发者ID:wisembly,项目名称:silexcms,代码行数:26,代码来源:DataMap.php


示例2: checkColumn

 /**
  * Do checks for columns.
  *
  * @param Column $column
  * @param array  $alterData
  *
  * @return boolean
  */
 protected function checkColumn(Column $column, array $alterData)
 {
     // Not needed to be implemented yet
     if ($alterData['propertyName'] !== $column->getName()) {
         return false;
     }
     return false;
 }
开发者ID:somekoala,项目名称:bolt,代码行数:16,代码来源:DiffUpdater.php


示例3: checkColumn

 /**
  * Do checks for columns.
  *
  * @param Column        $column
  * @param IgnoredChange $ignoredChange
  *
  * @return boolean
  */
 protected function checkColumn(Column $column, IgnoredChange $ignoredChange)
 {
     // Not needed to be implemented yet
     if ($ignoredChange->getPropertyName() !== $column->getName()) {
         return false;
     }
     return false;
 }
开发者ID:zomars,项目名称:bolt,代码行数:16,代码来源:DiffUpdater.php


示例4: generateField

 /**
  * @param \Doctrine\DBAL\Schema\Column $column
  * @param mixed $value
  */
 public function generateField($column, $value = null)
 {
     if ($value) {
         $this->value = $value;
     }
     $this->setLabel($column->getName());
     $this->name = $column->getName();
     return $this;
 }
开发者ID:albafo,项目名称:web.MagickLaravel,代码行数:13,代码来源:WysiwygField.php


示例5: testQuotedColumnName

 /**
  * @group DBAL-64
  */
 public function testQuotedColumnName()
 {
     $string = Type::getType('string');
     $column = new Column("`bar`", $string, array());
     $mysqlPlatform = new \Doctrine\DBAL\Platforms\MySqlPlatform();
     $sqlitePlatform = new \Doctrine\DBAL\Platforms\SqlitePlatform();
     $this->assertEquals('bar', $column->getName());
     $this->assertEquals('`bar`', $column->getQuotedName($mysqlPlatform));
     $this->assertEquals('"bar"', $column->getQuotedName($sqlitePlatform));
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:13,代码来源:ColumnTest.php


示例6: 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


示例7: getHtmlAttributes

 /**
  * @param \Doctrine\DBAL\Schema\Column $column
  * @param mixed $value
  * @return string
  */
 protected function getHtmlAttributes($column, $value = null)
 {
     $result = "";
     if (isset($value)) {
         $result .= "value='{$value}' ";
     }
     if ($name = $column->getName()) {
         $fieldName = $this->generateFieldName($name);
         $result .= "id='field_{$name}'  {$fieldName}";
     }
     return $result;
 }
开发者ID:albafo,项目名称:web.MagickLaravel,代码行数:17,代码来源:InputField.php


示例8: __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


示例9: _getPortableTableColumnDefinition

 /**
  * {@inheritdoc}
  */
 protected function _getPortableTableColumnDefinition($tableColumn)
 {
     $dbType = strtolower($tableColumn['DATA_TYPE']);
     $type = $this->_platform->getDoctrineTypeMapping($dbType);
     $type = $this->extractDoctrineTypeFromComment($tableColumn['COLUMN_COMMENT'], $type);
     $tableColumn['COLUMN_COMMENT'] = $this->removeDoctrineTypeFromComment($tableColumn['COLUMN_COMMENT'], $type);
     $options = array('notnull' => !(bool) $tableColumn['IS_NULLABLE'], 'length' => (int) $tableColumn['CHARACTER_MAXIMUM_LENGTH'], 'default' => isset($tableColumn['COLUMN_DEFAULT']) ? $tableColumn['COLUMN_DEFAULT'] : null, 'autoincrement' => (bool) $tableColumn['IS_AUTO_INCREMENT'], 'scale' => (int) $tableColumn['NUMERIC_SCALE'], 'precision' => (int) $tableColumn['NUMERIC_PRECISION'], 'comment' => isset($tableColumn['COLUMN_COMMENT']) && '' !== $tableColumn['COLUMN_COMMENT'] ? $tableColumn['COLUMN_COMMENT'] : null);
     $column = new Column($tableColumn['COLUMN_NAME'], Type::getType($type), $options);
     if (!empty($tableColumn['COLLATION_NAME'])) {
         $column->setPlatformOption('collation', $tableColumn['COLLATION_NAME']);
     }
     return $column;
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:16,代码来源:DrizzleSchemaManager.php


示例10: testGetIntegerColumnOptions

 public function testGetIntegerColumnOptions()
 {
     $this->assertPlatform();
     $this->platform->expects($this->once())->method('isCommentedDoctrineType')->will($this->returnValue(true));
     $column = new Column('string_column', Type::getType(Type::INTEGER));
     $column->setNotnull(false);
     $column->setAutoincrement(true);
     $column->setUnsigned(true);
     $result = $this->extension->getColumnOptions($column);
     $this->assertEquals(4, count($result));
     $this->assertTrue($result['unsigned']);
     $this->assertTrue($result['autoincrement']);
     $this->assertFalse($result['notnull']);
     $this->assertEquals('(DC2Type:integer)', $result['comment']);
 }
开发者ID:ramunasd,项目名称:platform,代码行数:15,代码来源:SchemaDumperExtensionTest.php


示例11: execute

 /**
  * Check for Sequence Duplicates.
  * 
  * Episodes of the same entity that overlap in time.
  * 
  * @access public
  * @return boolean the result of the operation
  * @param mixed     $oMixed     The Entity to do operation on
  */
 public function execute($oMixed)
 {
     $oOperation = $this->oOperation;
     $oConnection = $this->oConnection;
     # execute operation, only care if its successful
     $bResult = $oOperation->execute($oMixed);
     $sTableName = $this->sTableName;
     if (true === $bResult) {
         try {
             $oInnerQuery = new QueryBuilder($oConnection);
             $oInnerQuery->select('count(*)')->from($sTableName, 's2')->andWhere('s1.' . $this->oFromColum->getName() . ' < s2.' . $this->oToColumn->getName() . ' ')->andWhere('s2.' . $this->oFromColum->getName() . ' < s1.' . $this->oToColumn->getName() . ' ');
             # process the key columns
             foreach ($this->oNaturalKeyColumns as $oColumn) {
                 $oInnerQuery->andWhere('s1.' . $oColumn->getName() . ' = s2.' . $oColumn->getName() . ' ');
             }
             // verify the consistence
             $sSql = "SELECT count(*) FROM '.{$sTableName}.' AS s1\n                    WHERE 1 < (\n                        '.{$oInnerQuery->getSql}().'        \n                ); ";
             $iCount = (int) $oConnection->fetchColumn($sSql, array(), 0);
             if ($iCount > 0) {
                 throw new VoucherException('This entity has a sequence duplicate unable to finish operation');
             }
         } catch (DBALException $e) {
             throw new VoucherException($e->getMessage(), 0, $e);
         }
     }
     return $bResult;
 }
开发者ID:rayhan0421,项目名称:GeneralLedger,代码行数:36,代码来源:TemporalValidDecorator.php


示例12: getAddColumnSQL

 /**
  * @param string $tableName
  * @param string $columnName
  * @param \Doctrine\DBAL\Schema\Column $column
  * @return array
  */
 protected function getAddColumnSQL($tableName, $columnName, Column $column)
 {
     $query = array();
     $spatial = array('srid' => 4326, 'dimension' => 2, 'index' => false);
     foreach ($spatial as $key => &$val) {
         if ($column->hasCustomSchemaOption('spatial_' . $key)) {
             $val = $column->getCustomSchemaOption('spatial_' . $key);
         }
     }
     // Geometry columns are created by AddGeometryColumn stored procedure
     $query[] = sprintf("SELECT AddGeometryColumn('%s', '%s', %d, '%s', %d)", $tableName, $columnName, $spatial['srid'], strtoupper($column->getType()->getName()), $spatial['dimension']);
     if ($spatial['index']) {
         // Add a spatial index to the field
         $query[] = sprintf("Select CreateSpatialIndex('%s', '%s')", $tableName, $columnName);
     }
     return $query;
 }
开发者ID:nvdnkpr,项目名称:doctrine-spatial-sandbox,代码行数:23,代码来源:SqliteHandler.php


示例13: generateField

 /**
  * @param \Doctrine\DBAL\Schema\Column $column
  * @param mixed $value
  */
 public function generateField($column, $value = null)
 {
     $multiple = false;
     $options = $column->getValues();
     $options_temp = array();
     foreach ($options as $index => $option) {
         $option = str_replace("'", '', $option);
         $option = str_replace("\"", '', $option);
         $options_temp[$option] = $option;
     }
     $options = $options_temp;
     if (!$column->hasUniqueValue()) {
         $multiple = true;
     }
     $value = explode(",", $value);
     $name = $column->getName();
     return $this->generateFilledField($options, $name, $multiple, $value);
 }
开发者ID:albafo,项目名称:web.MagickLaravel,代码行数:22,代码来源:SelectField.php


示例14: _getPortableTableColumnDefinition

 /**
  * {@inheritdoc}
  */
 protected function _getPortableTableColumnDefinition($tableColumn)
 {
     $dbType = strtok($tableColumn['type'], '(), ');
     $fixed = null;
     $length = (int) $tableColumn['length'];
     $default = $tableColumn['default'];
     if (!isset($tableColumn['name'])) {
         $tableColumn['name'] = '';
     }
     while ($default != ($default2 = preg_replace("/^\\((.*)\\)\$/", '$1', $default))) {
         $default = trim($default2, "'");
         if ($default == 'getdate()') {
             $default = $this->_platform->getCurrentTimestampSQL();
         }
     }
     switch ($dbType) {
         case 'nchar':
         case 'nvarchar':
         case 'ntext':
             // Unicode data requires 2 bytes per character
             $length = $length / 2;
             break;
         case 'varchar':
             // TEXT type is returned as VARCHAR(MAX) with a length of -1
             if ($length == -1) {
                 $dbType = 'text';
             }
             break;
     }
     if ('char' === $dbType || 'nchar' === $dbType || 'binary' === $dbType) {
         $fixed = true;
     }
     $type = $this->_platform->getDoctrineTypeMapping($dbType);
     $type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type);
     $tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type);
     $options = array('length' => $length == 0 || !in_array($type, array('text', 'string')) ? null : $length, 'unsigned' => false, 'fixed' => (bool) $fixed, 'default' => $default !== 'NULL' ? $default : null, 'notnull' => (bool) $tableColumn['notnull'], 'scale' => $tableColumn['scale'], 'precision' => $tableColumn['precision'], 'autoincrement' => (bool) $tableColumn['autoincrement'], 'comment' => $tableColumn['comment'] !== '' ? $tableColumn['comment'] : null);
     $column = new Column($tableColumn['name'], Type::getType($type), $options);
     if (isset($tableColumn['collation']) && $tableColumn['collation'] !== 'NULL') {
         $column->setPlatformOption('collation', $tableColumn['collation']);
     }
     return $column;
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:45,代码来源:SQLServerSchemaManager.php


示例15: getSql

 public function getSql(Column $column, $table)
 {
     if (!$table instanceof Table) {
         $table = new Identifier($table);
     }
     $sql = array();
     $normalized = $column->getType()->getNormalizedPostGISColumnOptions($column->getCustomSchemaOptions());
     $srid = $normalized['srid'];
     // PostGIS 1.5 uses -1 for undefined SRID's
     if ($srid <= 0) {
         $srid = -1;
     }
     $type = strtoupper($normalized['geometry_type']);
     if ('ZM' === substr($type, -2)) {
         $dimension = 4;
         $type = substr($type, 0, -2);
     } elseif ('M' === substr($type, -1)) {
         $dimension = 3;
     } elseif ('Z' === substr($type, -1)) {
         $dimension = 3;
         $type = substr($type, 0, -1);
     } else {
         $dimension = 2;
     }
     // Geometry columns are created by the AddGeometryColumn stored procedure
     $sql[] = sprintf("SELECT AddGeometryColumn('%s', '%s', %d, '%s', %d)", $table->getName(), $column->getName(), $srid, $type, $dimension);
     if ($column->getNotnull()) {
         // Add a NOT NULL constraint to the field
         $sql[] = sprintf('ALTER TABLE %s ALTER %s SET NOT NULL', $table->getQuotedName($this->platform), $column->getQuotedName($this->platform));
     }
     return $sql;
 }
开发者ID:novikovsergey,项目名称:doctrine-postgis,代码行数:32,代码来源:SpatialColumnSqlGenerator.php


示例16: 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


示例17: getType

 protected function getType(Column $column)
 {
     $type = 0;
     if ($column->getLength() > 0) {
         $type += $column->getLength();
     }
     $type = $type | SerializeTrait::getTypeByDoctrineType($column->getType());
     if (!$column->getNotnull()) {
         $type = $type | TableInterface::IS_NULL;
     }
     if ($column->getAutoincrement()) {
         $type = $type | TableInterface::AUTO_INCREMENT;
     }
     return $type;
 }
开发者ID:seytar,项目名称:psx,代码行数:15,代码来源:Schema.php


示例18: buildColumn

 /**
  * @param Column $column
  * @param Collection $foreignKeyColumns
  * @param Collection $foreignTables
  * @param Collection $indexes
  * @return ColumnInterface
  */
 protected function buildColumn(Column $column, Collection $foreignKeyColumns, Collection $foreignTables, Collection $indexes)
 {
     $uniqued = $indexes->filter(function (Index $index) use($column) {
         return $index->getColumns()[0] == $column->getName() && $index->isUnique();
     })->count() > 0;
     if ($column->getAutoincrement()) {
         return new ColumnAutoincrement($column, null, null, $uniqued);
     } else {
         if ($foreignKeyColumns->has($column->getName())) {
             $table = $foreignKeyColumns->get($column->getName());
             return new ColumnSelect($column, $table, $foreignTables->get($table), $uniqued);
         } else {
             if ($column->getType()->getName() == Type::INTEGER) {
                 return new ColumnNumericText($column, null, null, $uniqued);
             } else {
                 return new ColumnText($column, null, null, $uniqued);
             }
         }
     }
 }
开发者ID:shin1x1,项目名称:laravel-table-admin,代码行数:27,代码来源:ColumnCollectionFactory.php


示例19: getAlterTableRenameColumnClause

 /**
  * Returns the SQL clause for renaming a column in a table alteration.
  *
  * @param string $oldColumnName The quoted name of the column to rename.
  * @param Column $column        The column to rename to.
  *
  * @return string
  */
 protected function getAlterTableRenameColumnClause($oldColumnName, Column $column)
 {
     $oldColumnName = new Identifier($oldColumnName);
     return 'RENAME ' . $oldColumnName->getQuotedName($this) . ' TO ' . $column->getQuotedName($this);
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:13,代码来源:SQLAnywherePlatform.php


示例20: diffColumn

 public function diffColumn(Column $column1, Column $column2)
 {
     $changedProperties = array();
     if ($column1->getType() != $column2->getType()) {
         //espo: fix problem with executing query for custom types
         $column1DbTypeName = method_exists($column1->getType(), 'getDbTypeName') ? $column1->getType()->getDbTypeName() : $column1->getType()->getName();
         $column2DbTypeName = method_exists($column2->getType(), 'getDbTypeName') ? $column2->getType()->getDbTypeName() : $column2->getType()->getName();
         if (strtolower($column1DbTypeName) != strtolower($column2DbTypeName)) {
             $changedProperties[] = 'type';
         }
         //END: espo
     }
     if ($column1->getNotnull() != $column2->getNotnull()) {
         $changedProperties[] = 'notnull';
     }
     if ($column1->getDefault() != $column2->getDefault()) {
         $changedProperties[] = 'default';
     }
     if ($column1->getUnsigned() != $column2->getUnsigned()) {
         $changedProperties[] = 'unsigned';
     }
     if ($column1->getType() instanceof \Doctrine\DBAL\Types\StringType) {
         // check if value of length is set at all, default value assumed otherwise.
         $length1 = $column1->getLength() ?: 255;
         $length2 = $column2->getLength() ?: 255;
         /** Fox: column length can be increased only */
         /*if ($length1 != $length2) {
               $changedProperties[] = 'length';
           }*/
         if ($length2 > $length1) {
             $changedProperties[] = 'length';
         }
         /** Fox: end */
         if ($column1->getFixed() != $column2->getFixed()) {
             $changedProperties[] = 'fixed';
         }
     }
     if ($column1->getType() instanceof \Doctrine\DBAL\Types\DecimalType) {
         if (($column1->getPrecision() ?: 10) != ($column2->getPrecision() ?: 10)) {
             $changedProperties[] = 'precision';
         }
         if ($column1->getScale() != $column2->getScale()) {
             $changedProperties[] = 'scale';
         }
     }
     if ($column1->getAutoincrement() != $column2->getAutoincrement()) {
         $changedProperties[] = 'autoincrement';
     }
     // only allow to delete comment if its set to '' not to null.
     if ($column1->getComment() !== null && $column1->getComment() != $column2->getComment()) {
         $changedProperties[] = 'comment';
     }
     $options1 = $column1->getCustomSchemaOptions();
     $options2 = $column2->getCustomSchemaOptions();
     $commonKeys = array_keys(array_intersect_key($options1, $options2));
     foreach ($commonKeys as $key) {
         if ($options1[$key] !== $options2[$key]) {
             $changedProperties[] = $key;
         }
     }
     $diffKeys = array_keys(array_diff_key($options1, $options2) + array_diff_key($options2, $options1));
     $changedProperties = array_merge($changedProperties, $diffKeys);
     return $changedProperties;
 }
开发者ID:chinazan,项目名称:zzcrm,代码行数:64,代码来源:Comparator.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Schema\Comparator类代码示例发布时间:2022-05-23
下一篇:
PHP Schema\AbstractSchemaManager类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap