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


PHP Column::getComment方法代码示例

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


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

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

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

示例3: __construct

 public function __construct(TableInformation $parent, \Doctrine\DBAL\Schema\Table $table, \Doctrine\DBAL\Schema\Column $column)
 {
     $this->table = $parent;
     foreach ($table->getForeignKeys() as $foreign) {
         if (in_array($column->getName(), $foreign->getColumns())) {
             $foreign_columns = $foreign->getForeignColumns();
             $this->foreignTable = $foreign->getForeignTableName();
             $this->foreignColumn = reset($foreign_columns);
             $this->isForeign = true;
         }
     }
     if ($primary_key = $table->getPrimaryKey()) {
         $this->isPrimary = in_array($column->getName(), $primary_key->getColumns());
     }
     $this->name = $column->getName();
     $this->type = $column->getType()->getName();
     $this->length = $column->getLength();
     $this->precision = $column->getPrecision();
     $this->default = $column->getDefault();
     $this->isNotNull = $column->getNotnull();
     $this->isUnsigned = $column->getUnsigned();
     $this->isFixed = $column->getFixed();
     $this->isAutoIncrement = $column->getAutoincrement();
     $this->comment = $column->getComment();
     if ($this->type === \Doctrine\DBAL\Types\Type::BLOB) {
         $this->length = min($this->bytesFromIni('post_max_size'), $this->bytesFromIni('upload_max_filesize'));
     }
 }
开发者ID:alanedwardes,项目名称:carbo,代码行数:28,代码来源:ColumnInformation.php

示例4: 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;
         if ($length1 != $length2) {
             $changedProperties[] = 'length';
         }
         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:jdavis593,项目名称:appitechture,代码行数:59,代码来源:Comparator.php

示例5: buildFieldMapping

 /**
  * Build field mapping from a schema column definition
  *
  * @param string                       $tableName
  * @param \Doctrine\DBAL\Schema\Column $column
  *
  * @return array
  */
 private function buildFieldMapping($tableName, Column $column)
 {
     $fieldMapping = array('fieldName' => $this->getFieldNameForColumn($tableName, $column->getName(), false), 'columnName' => $column->getName(), 'type' => $column->getType()->getName(), 'nullable' => !$column->getNotNull());
     // Type specific elements
     switch ($fieldMapping['type']) {
         case Type::TARRAY:
         case Type::BLOB:
         case Type::GUID:
         case Type::JSON_ARRAY:
         case Type::OBJECT:
         case Type::SIMPLE_ARRAY:
         case Type::STRING:
         case Type::TEXT:
             $fieldMapping['length'] = $column->getLength();
             $fieldMapping['options']['fixed'] = $column->getFixed();
             break;
         case Type::DECIMAL:
         case Type::FLOAT:
             $fieldMapping['precision'] = $column->getPrecision();
             $fieldMapping['scale'] = $column->getScale();
             break;
         case Type::INTEGER:
         case Type::BIGINT:
         case Type::SMALLINT:
             $fieldMapping['options']['unsigned'] = $column->getUnsigned();
             break;
     }
     // Comment
     if (($comment = $column->getComment()) !== null) {
         $fieldMapping['options']['comment'] = $comment;
     }
     // Weather
     if (($default = $column->getDefault()) !== null) {
         $fieldMapping['options']['default'] = $default;
     }
     return $fieldMapping;
 }
开发者ID:rolas123,项目名称:weather-homework,代码行数:45,代码来源:DatabaseDriver.php

示例6: getColumnComment

 /**
  * Return the comment of a passed column modified by potential doctrine type comment hints.
  *
  * @param Column $column
  * @return string
  */
 protected function getColumnComment(Column $column)
 {
     $comment = $column->getComment();
     if ($this->isCommentedDoctrineType($column->getType())) {
         $comment .= $this->getDoctrineTypeComment($column->getType());
     }
     return $comment;
 }
开发者ID:pollux1er,项目名称:dlawebdev2,代码行数:14,代码来源:AbstractPlatform.php

示例7: hasCommentTag

 /**
  * @param Column $column
  * @param $tag
  * @return bool
  */
 public function hasCommentTag(Column $column, $tag)
 {
     $pos = stripos($column->getComment(), '#' . $tag);
     return $pos !== false;
 }
开发者ID:kabirbaidhya,项目名称:pharam,代码行数:10,代码来源:ColumnHelper.php

示例8: colConfig

 /**
  * @param Column $col
  * @return array
  */
 protected function colConfig(Column $col)
 {
     $conf = [];
     //var_dump($col->toArray()); //, $col->getType()->getTypesMap());
     $fieldClass = self::$dbType2FieldClass[$col->getType()->getName()];
     $fieldName = $col->getName();
     if ($col->getAutoincrement()) {
         $fieldClass = 'Auto';
     } elseif (substr($col->getName(), -3) === '_id') {
         $fieldClass = 'ForeignKey';
         $fk_tbl = substr($col->getName(), 0, strpos($col->getName(), '_id'));
         $fieldName = $fk_tbl;
         $conf['relationClass'] = $this->table2model($fk_tbl);
         $conf['db_column'] = $col->getName();
         if (!isset($this->generated[$fk_tbl])) {
             $this->generateQueue[] = $fk_tbl;
         }
     }
     array_unshift($conf, $fieldClass);
     if ($this->dp->getReservedKeywordsList()->isKeyword($col->getName())) {
         $conf['db_column'] = 'f_' . $col->getName();
     }
     if ($col->getNotnull() === false) {
         $conf['null'] = true;
     }
     if ($col->getLength() !== null) {
         $conf['max_length'] = $col->getLength();
     }
     if ($col->getDefault() !== null) {
         if ($col->getDefault() !== 'CURRENT_TIMESTAMP') {
             $conf['default'] = $col->getType()->convertToPHPValue($col->getDefault(), $this->dp);
             if ($conf['default'] === '') {
                 $conf['blank'] = true;
             }
         }
     }
     if ($col->getComment() !== null) {
         $help = $col->getComment();
         if (strpos($help, PHP_EOL) !== false) {
             $help = str_replace(PHP_EOL, '', $help);
         }
         $conf['help_text'] = $help;
     }
     return [$fieldName, $conf];
 }
开发者ID:buldezir,项目名称:dja_orm,代码行数:49,代码来源:Introspection.php


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