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


PHP Schema\Column类代码示例

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


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


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