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


PHP Column::addVendorInfo方法代码示例

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


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

示例1: testGetColumnDDLCharsetNotNull

 public function testGetColumnDDLCharsetNotNull()
 {
     $column = new Column('foo');
     $column->getDomain()->copy($this->getPlatform()->getDomainForType('LONGVARCHAR'));
     $column->setNotNull(true);
     $vendor = new VendorInfo('mysql');
     $vendor->setParameter('Charset', 'greek');
     $column->addVendorInfo($vendor);
     $expected = '`foo` TEXT CHARACTER SET \'greek\' NOT NULL';
     $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column));
 }
开发者ID:SwissalpS,项目名称:Propel2,代码行数:11,代码来源:MysqlPlatformMyISAMTest.php

示例2: getColumnFromRow

 /**
  * Factory method creating a Column object
  * based on a row from the 'show columns from ' MySQL query result.
  *
  * @param     array $row An associative array with the following keys:
  *                       Field, Type, Null, Key, Default, Extra.
  * @return    Column
  */
 public function getColumnFromRow($row, Table $table)
 {
     $name = $row['Field'];
     $is_nullable = $row['Null'] == 'YES';
     $autoincrement = strpos($row['Extra'], 'auto_increment') !== false;
     $size = null;
     $precision = null;
     $scale = null;
     $sqlType = false;
     $regexp = '/^
         (\\w+)        # column type [1]
         [\\(]         # (
             ?([\\d,]*)  # size or size, precision [2]
         [\\)]         # )
         ?\\s*         # whitespace
         (\\w*)        # extra description (UNSIGNED, CHARACTER SET, ...) [3]
     $/x';
     if (preg_match($regexp, $row['Type'], $matches)) {
         $nativeType = $matches[1];
         if ($matches[2]) {
             if (($cpos = strpos($matches[2], ',')) !== false) {
                 $size = (int) substr($matches[2], 0, $cpos);
                 $precision = $size;
                 $scale = (int) substr($matches[2], $cpos + 1);
             } else {
                 $size = (int) $matches[2];
             }
         }
         if ($matches[3]) {
             $sqlType = $row['Type'];
         }
         foreach (self::$defaultTypeSizes as $type => $defaultSize) {
             if ($nativeType == $type && $size == $defaultSize) {
                 $size = null;
                 continue;
             }
         }
     } elseif (preg_match('/^(\\w+)\\(/', $row['Type'], $matches)) {
         $nativeType = $matches[1];
         if ($nativeType == 'enum') {
             $sqlType = $row['Type'];
         }
     } else {
         $nativeType = $row['Type'];
     }
     //BLOBs can't have any default values in MySQL
     $default = preg_match('~blob|text~', $nativeType) ? null : $row['Default'];
     $propelType = $this->getMappedPropelType($nativeType);
     if (!$propelType) {
         $propelType = Column::DEFAULT_TYPE;
         $sqlType = $row['Type'];
         $this->warn("Column [" . $table->getName() . "." . $name . "] has a column type (" . $nativeType . ") that Propel does not support.");
     }
     // Special case for TINYINT(1) which is a BOOLEAN
     if (PropelTypes::TINYINT === $propelType && 1 === $size) {
         $propelType = PropelTypes::BOOLEAN;
     }
     $column = new Column($name);
     $column->setTable($table);
     $column->setDomainForType($propelType);
     if ($sqlType) {
         $column->getDomain()->replaceSqlType($sqlType);
     }
     $column->getDomain()->replaceSize($size);
     $column->getDomain()->replaceScale($scale);
     if ($default !== null) {
         if ($propelType == PropelTypes::BOOLEAN) {
             if ($default == '1') {
                 $default = 'true';
             }
             if ($default == '0') {
                 $default = 'false';
             }
         }
         if (in_array($default, array('CURRENT_TIMESTAMP'))) {
             $type = ColumnDefaultValue::TYPE_EXPR;
         } else {
             $type = ColumnDefaultValue::TYPE_VALUE;
         }
         $column->getDomain()->setDefaultValue(new ColumnDefaultValue($default, $type));
     }
     $column->setAutoIncrement($autoincrement);
     $column->setNotNull(!$is_nullable);
     if ($this->addVendorInfo) {
         $vi = $this->getNewVendorInfoObject($row);
         $column->addVendorInfo($vi);
     }
     return $column;
 }
开发者ID:RafalFilipek,项目名称:Propel2,代码行数:97,代码来源:MysqlSchemaParser.php

示例3: Column

$column42 = new Column('name', 'varchar', 40);
$column42->setNotNull();
$column51 = new Column('post_id', 'integer', 7);
$column51->setNotNull();
$column51->setPrimaryKey();
$column52 = new Column('tag_id', 'integer', 7);
$column52->setNotNull();
$column52->setPrimaryKey();
$column61 = new Column('id', 'integer', 5);
$column61->setNotNull();
$column61->setAutoIncrement();
$column61->setPrimaryKey();
$column62 = new Column('title', 'varchar', 150);
$column62->setNotNull();
$column63 = new Column('content', 'clob');
$column63->addVendorInfo(new VendorInfo('mysql', ['Charset' => 'latin1', 'Collate' => 'latin1_general_ci']));
$column64 = new Column('is_published', 'boolean');
$column64->setNotNull();
$column64->setDefaultValue('false');
/* Foreign Keys */
$fkAuthorPost = new ForeignKey('fk_post_has_author');
$fkAuthorPost->addReference('author_id', 'id');
$fkAuthorPost->setForeignTableCommonName('blog_author');
$fkAuthorPost->setRefPhpName('Posts');
$fkAuthorPost->setPhpName('Author');
$fkAuthorPost->setDefaultJoin('Criteria::LEFT_JOIN');
$fkAuthorPost->setOnDelete('CASCADE');
$fkCategoryPost = new ForeignKey('fk_post_has_category');
$fkCategoryPost->addReference('category_id', 'id');
$fkCategoryPost->setForeignTableCommonName('blog_category');
$fkCategoryPost->setRefPhpName('Posts');
开发者ID:disider,项目名称:Propel2,代码行数:31,代码来源:blog-database.php

示例4: startElement

 public function startElement($parser, $name, $attributes)
 {
     $parentTag = $this->peekCurrentSchemaTag();
     if (false === $parentTag) {
         switch ($name) {
             case 'database':
                 if ($this->isExternalSchema()) {
                     $this->currentPackage = isset($attributes['package']) ? $attributes['package'] : null;
                     if (null === $this->currentPackage) {
                         $this->currentPackage = $this->defaultPackage;
                     }
                 } else {
                     $this->currDB = $this->schema->addDatabase($attributes);
                 }
                 break;
             default:
                 $this->_throwInvalidTagException($parser, $name);
         }
     } elseif ('database' === $parentTag) {
         switch ($name) {
             case 'external-schema':
                 $xmlFile = isset($attributes['filename']) ? $attributes['filename'] : null;
                 // 'referenceOnly' attribute is valid in the main schema XML file only,
                 // and it's ignored in the nested external-schemas
                 if (!$this->isExternalSchema()) {
                     $isForRefOnly = isset($attributes['referenceOnly']) ? $attributes['referenceOnly'] : null;
                     $this->isForReferenceOnly = null !== $isForRefOnly ? 'true' === strtolower($isForRefOnly) : true;
                     // defaults to TRUE
                 }
                 if ('/' !== $xmlFile[0]) {
                     $xmlFile = realpath(dirname($this->currentXmlFile) . DIRECTORY_SEPARATOR . $xmlFile);
                     if (!file_exists($xmlFile)) {
                         throw new SchemaException(sprintf('Unknown include external "%s"', $xmlFile));
                     }
                 }
                 $this->parseFile($xmlFile);
                 break;
             case 'domain':
                 $this->currDB->addDomain($attributes);
                 break;
             case 'table':
                 if (!isset($attributes['schema']) && $this->currDB->getSchema() && $this->currDB->getPlatform()->supportsSchemas() && false === strpos($attributes['name'], $this->currDB->getPlatform()->getSchemaDelimiter())) {
                     $attributes['schema'] = $this->currDB->getSchema();
                 }
                 $this->currTable = $this->currDB->addTable($attributes);
                 if ($this->isExternalSchema()) {
                     $this->currTable->setForReferenceOnly($this->isForReferenceOnly);
                     $this->currTable->setPackage($this->currentPackage);
                 }
                 break;
             case 'vendor':
                 $this->currVendorObject = $this->currDB->addVendorInfo($attributes);
                 break;
             case 'behavior':
                 $this->currBehavior = $this->currDB->addBehavior($attributes);
                 break;
             default:
                 $this->_throwInvalidTagException($parser, $name);
         }
     } elseif ('table' === $parentTag) {
         switch ($name) {
             case 'column':
                 $this->currColumn = $this->currTable->addColumn($attributes);
                 break;
             case 'foreign-key':
                 $this->currFK = $this->currTable->addForeignKey($attributes);
                 break;
             case 'index':
                 $this->currIndex = new Index();
                 $this->currIndex->setTable($this->currTable);
                 $this->currIndex->loadMapping($attributes);
                 break;
             case 'unique':
                 $this->currUnique = new Unique();
                 $this->currUnique->setTable($this->currTable);
                 $this->currUnique->loadMapping($attributes);
                 break;
             case 'vendor':
                 $this->currVendorObject = $this->currTable->addVendorInfo($attributes);
                 break;
             case 'id-method-parameter':
                 $this->currTable->addIdMethodParameter($attributes);
                 break;
             case 'behavior':
                 $this->currBehavior = $this->currTable->addBehavior($attributes);
                 break;
             default:
                 $this->_throwInvalidTagException($parser, $name);
         }
     } elseif ('column' === $parentTag) {
         switch ($name) {
             case 'inheritance':
                 $this->currColumn->addInheritance($attributes);
                 break;
             case 'vendor':
                 $this->currVendorObject = $this->currColumn->addVendorInfo($attributes);
                 break;
             default:
                 $this->_throwInvalidTagException($parser, $name);
         }
//.........这里部分代码省略.........
开发者ID:malukenho,项目名称:Propel2,代码行数:101,代码来源:SchemaReader.php


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