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


PHP Column::getDomain方法代码示例

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


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

示例1: addClosureColumn

 protected function addClosureColumn($name, Table $ct_table, Column $column)
 {
     $table = $this->getTable();
     $id_fieldname = $column->getName();
     $domain = $column->getDomain();
     if (!$ct_table->hasColumn($name)) {
         $column = new Column($name);
         $column->setDomain($domain);
         $column->setPrimaryKey(true);
         $ct_table->addColumn($column);
     } else {
         $column = $ct_table->getColumn($name);
     }
     $ct_tablename_normalized = str_replace('_', '', $ct_table->getName());
     $fk_name = $ct_tablename_normalized . '_' . $name . '_fk';
     if (!$ct_table->getColumnForeignKeys($name)) {
         $column_fk = new ForeignKey($fk_name);
         $column_fk->addReference($name, $table->getColumn($id_fieldname)->getName());
         $column_fk->setForeignTableCommonName($table->getName());
         $column_fk->setOnUpdate('cascade');
         $column_fk->setOnDelete('restrict');
         $ct_table->addForeignKey($column_fk);
     }
     $column_idx_name = $fk_name . '_idx';
     if (!$ct_table->hasIndex($column_idx_name)) {
         $column_idx = new Index($column_idx_name);
         $column_idx->addColumn(['name' => $column->getName()]);
         $ct_table->addIndex($column_idx);
     }
 }
开发者ID:scif,项目名称:propel-closuretable-behavior,代码行数:30,代码来源:ClosureTableBehavior.php

示例2: compareColumns

 public static function compareColumns(Column $fromColumn, Column $toColumn)
 {
     $changedProperties = [];
     // compare column types
     $fromDomain = $fromColumn->getDomain();
     $toDomain = $toColumn->getDomain();
     if ($fromDomain->getScale() !== $toDomain->getScale()) {
         $changedProperties['scale'] = [$fromDomain->getScale(), $toDomain->getScale()];
     }
     if ($fromDomain->getSize() !== $toDomain->getSize()) {
         $changedProperties['size'] = [$fromDomain->getSize(), $toDomain->getSize()];
     }
     if (strtoupper($fromDomain->getSqlType()) !== strtoupper($toDomain->getSqlType())) {
         if ($fromDomain->getOriginSqlType()) {
             if (strtoupper($fromDomain->getOriginSqlType()) !== strtoupper($toDomain->getSqlType())) {
                 if ($fromDomain->getType() !== $toDomain->getType()) {
                     $changedProperties['type'] = [$fromDomain->getType(), $toDomain->getType()];
                 }
                 $changedProperties['sqlType'] = [$fromDomain->getSqlType(), $toDomain->getSqlType()];
             }
         } else {
             $changedProperties['sqlType'] = [$fromDomain->getSqlType(), $toDomain->getSqlType()];
             if ($fromDomain->getType() !== $toDomain->getType()) {
                 $changedProperties['type'] = [$fromDomain->getType(), $toDomain->getType()];
             }
         }
     }
     if ($fromColumn->isNotNull() !== $toColumn->isNotNull()) {
         $changedProperties['notNull'] = [$fromColumn->isNotNull(), $toColumn->isNotNull()];
     }
     // compare column default value
     $fromDefaultValue = $fromColumn->getDefaultValue();
     $toDefaultValue = $toColumn->getDefaultValue();
     if ($fromDefaultValue && !$toDefaultValue) {
         $changedProperties['defaultValueType'] = [$fromDefaultValue->getType(), null];
         $changedProperties['defaultValueValue'] = [$fromDefaultValue->getValue(), null];
     } elseif (!$fromDefaultValue && $toDefaultValue) {
         $changedProperties['defaultValueType'] = [null, $toDefaultValue->getType()];
         $changedProperties['defaultValueValue'] = [null, $toDefaultValue->getValue()];
     } elseif ($fromDefaultValue && $toDefaultValue) {
         if (!$fromDefaultValue->equals($toDefaultValue)) {
             if ($fromDefaultValue->getType() !== $toDefaultValue->getType()) {
                 $changedProperties['defaultValueType'] = [$fromDefaultValue->getType(), $toDefaultValue->getType()];
             }
             if ($fromDefaultValue->getValue() !== $toDefaultValue->getValue()) {
                 $changedProperties['defaultValueValue'] = [$fromDefaultValue->getValue(), $toDefaultValue->getValue()];
             }
         }
     }
     if ($fromColumn->isAutoIncrement() !== $toColumn->isAutoIncrement()) {
         $changedProperties['autoIncrement'] = [$fromColumn->isAutoIncrement(), $toColumn->isAutoIncrement()];
     }
     return $changedProperties;
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:54,代码来源:ColumnComparator.php

示例3: getColumnDDL

 public function getColumnDDL(Column $col)
 {
     $domain = $col->getDomain();
     $sqlType = $domain->getSqlType();
     $notNullString = $this->getNullString($col->isNotNull());
     $defaultSetting = $this->getColumnDefaultValueDDL($col);
     // Special handling of TIMESTAMP/DATETIME types ...
     // See: http://propel.phpdb.org/trac/ticket/538
     if ($sqlType == 'DATETIME') {
         $def = $domain->getDefaultValue();
         if ($def && $def->isExpression()) {
             // DATETIME values can only have constant expressions
             $sqlType = 'TIMESTAMP';
         }
     } elseif ($sqlType == 'DATE') {
         $def = $domain->getDefaultValue();
         if ($def && $def->isExpression()) {
             throw new EngineException('DATE columns cannot have default *expressions* in MySQL.');
         }
     } elseif ($sqlType == 'TEXT' || $sqlType == 'BLOB') {
         if ($domain->getDefaultValue()) {
             throw new EngineException('BLOB and TEXT columns cannot have DEFAULT values. in MySQL.');
         }
     }
     $ddl = array($this->quoteIdentifier($col->getName()));
     if ($this->hasSize($sqlType) && $col->isDefaultSqlType($this)) {
         $ddl[] = $sqlType . $col->getSizeDefinition();
     } else {
         $ddl[] = $sqlType;
     }
     $colinfo = $col->getVendorInfoForType($this->getDatabaseType());
     if ($colinfo->hasParameter('Charset')) {
         $ddl[] = 'CHARACTER SET ' . $this->quote($colinfo->getParameter('Charset'));
     }
     if ($colinfo->hasParameter('Collation')) {
         $ddl[] = 'COLLATE ' . $this->quote($colinfo->getParameter('Collation'));
     } elseif ($colinfo->hasParameter('Collate')) {
         $ddl[] = 'COLLATE ' . $this->quote($colinfo->getParameter('Collate'));
     }
     if ($sqlType == 'TIMESTAMP') {
         if ($notNullString == '') {
             $notNullString = 'NULL';
         }
         if ($defaultSetting == '' && $notNullString == 'NOT NULL') {
             $defaultSetting = 'DEFAULT CURRENT_TIMESTAMP';
         }
         if ($notNullString) {
             $ddl[] = $notNullString;
         }
         if ($defaultSetting) {
             $ddl[] = $defaultSetting;
         }
     } else {
         if ($defaultSetting) {
             $ddl[] = $defaultSetting;
         }
         if ($notNullString) {
             $ddl[] = $notNullString;
         }
     }
     if ($autoIncrement = $col->getAutoIncrementString()) {
         $ddl[] = $autoIncrement;
     }
     if ($col->getDescription()) {
         $ddl[] = 'COMMENT ' . $this->quote($col->getDescription());
     }
     return implode(' ', $ddl);
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:68,代码来源:MysqlPlatform.php

示例4: testCompareSeveralRenamedSameColumns

 public function testCompareSeveralRenamedSameColumns()
 {
     $t1 = new Table();
     $c1 = new Column('col1');
     $c1->getDomain()->copy($this->platform->getDomainForType('VARCHAR'));
     $c1->getDomain()->replaceSize(255);
     $t1->addColumn($c1);
     $c2 = new Column('col2');
     $c2->getDomain()->copy($this->platform->getDomainForType('VARCHAR'));
     $c2->getDomain()->replaceSize(255);
     $t1->addColumn($c2);
     $c3 = new Column('col3');
     $c3->getDomain()->copy($this->platform->getDomainForType('VARCHAR'));
     $c3->getDomain()->replaceSize(255);
     $t1->addColumn($c3);
     $t2 = new Table();
     $c4 = new Column('col4');
     $c4->getDomain()->copy($this->platform->getDomainForType('VARCHAR'));
     $c4->getDomain()->replaceSize(255);
     $t2->addColumn($c4);
     $c5 = new Column('col5');
     $c5->getDomain()->copy($this->platform->getDomainForType('VARCHAR'));
     $c5->getDomain()->replaceSize(255);
     $t2->addColumn($c5);
     $c6 = new Column('col3');
     $c6->getDomain()->copy($this->platform->getDomainForType('VARCHAR'));
     $c6->getDomain()->replaceSize(255);
     $t2->addColumn($c6);
     // col1 and col2 were renamed
     $tc = new TableComparator();
     $tc->setFromTable($t1);
     $tc->setToTable($t2);
     $nbDiffs = $tc->compareColumns();
     $tableDiff = $tc->getTableDiff();
     $this->assertEquals(2, $nbDiffs);
     $this->assertEquals([[$c1, $c4], [$c2, $c5]], $tableDiff->getRenamedColumns());
     $this->assertEquals([], $tableDiff->getAddedColumns());
     $this->assertEquals([], $tableDiff->getRemovedColumns());
     $this->assertEquals([], $tableDiff->getModifiedColumns());
 }
开发者ID:disider,项目名称:Propel2,代码行数:40,代码来源:PropelTableColumnComparatorTest.php

示例5: addColumns

 /**
  * Adds Columns to the specified table.
  *
  * @param Table $table The Table model class to add columns to.
  */
 protected function addColumns(Table $table)
 {
     $stmt = $this->dbh->query("PRAGMA table_info('" . $table->getName() . "')");
     while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
         $name = $row['name'];
         $fulltype = $row['type'];
         $size = null;
         $precision = null;
         $scale = null;
         if (preg_match('/^([^\\(]+)\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\)$/', $fulltype, $matches)) {
             $type = $matches[1];
             $precision = $matches[2];
             $scale = $matches[3];
             // aka precision
         } elseif (preg_match('/^([^\\(]+)\\(\\s*(\\d+)\\s*\\)$/', $fulltype, $matches)) {
             $type = $matches[1];
             $size = $matches[2];
         } else {
             $type = $fulltype;
         }
         // If column is primary key and of type INTEGER, it is auto increment
         // See: http://sqlite.org/faq.html#q1
         $autoincrement = 1 == $row['pk'] && 'integer' === strtolower($type);
         $notNull = $row['notnull'];
         $default = $row['dflt_value'];
         $propelType = $this->getMappedPropelType(strtolower($type));
         if (!$propelType) {
             $propelType = Column::DEFAULT_TYPE;
             $this->warn('Column [' . $table->getName() . '.' . $name . '] has a column type (' . $type . ') that Propel does not support.');
         }
         $column = new Column($name);
         $column->setTable($table);
         $column->setDomainForType($propelType);
         // We may want to provide an option to include this:
         // $column->getDomain()->replaceSqlType($type);
         $column->getDomain()->replaceSize($size);
         $column->getDomain()->replaceScale($scale);
         if (null !== $default) {
             $column->getDomain()->setDefaultValue(new ColumnDefaultValue($default, ColumnDefaultValue::TYPE_VALUE));
         }
         $column->setAutoIncrement($autoincrement);
         $column->setNotNull($notNull);
         if (1 == $row['pk'] || 'integer' === strtolower($type)) {
             $column->setPrimaryKey(true);
         }
         $table->addColumn($column);
     }
 }
开发者ID:robin850,项目名称:Propel2,代码行数:53,代码来源:SqliteSchemaParser.php

示例6: addColumns

 /**
  * Adds Columns to the specified table.
  *
  * @param Table $table The Table model class to add columns to.
  */
 protected function addColumns(Table $table)
 {
     $dataFetcher = $this->dbh->query("sp_columns '" . $table->getName() . "'");
     foreach ($dataFetcher as $row) {
         $name = $this->cleanDelimitedIdentifiers($row['COLUMN_NAME']);
         $type = $row['TYPE_NAME'];
         $size = $row['LENGTH'];
         $isNullable = $row['NULLABLE'];
         $default = $row['COLUMN_DEF'];
         $scale = $row['SCALE'];
         $autoincrement = false;
         if (strtolower($type) == 'int identity') {
             $autoincrement = true;
         }
         $propelType = $this->getMappedPropelType($type);
         if (!$propelType) {
             $propelType = Column::DEFAULT_TYPE;
             $this->warn(sprintf('Column [%s.%s] has a column type (%s) that Propel does not support.', $table->getName(), $name, $type));
         }
         $column = new Column($name);
         $column->setTable($table);
         $column->setDomainForType($propelType);
         $column->getDomain()->setOriginSqlType($type);
         // We may want to provide an option to include this:
         // $column->getDomain()->replaceSqlType($type);
         $column->getDomain()->replaceSize($size);
         $column->getDomain()->replaceScale($scale);
         if ($default !== null) {
             $column->getDomain()->setDefaultValue(new ColumnDefaultValue($default, ColumnDefaultValue::TYPE_VALUE));
         }
         $column->setAutoIncrement($autoincrement);
         $column->setNotNull(!$isNullable);
         $table->addColumn($column);
     }
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:40,代码来源:MssqlSchemaParser.php

示例7: providerForTestGetModifyColumnRemoveDefaultValueDDL

 public function providerForTestGetModifyColumnRemoveDefaultValueDDL()
 {
     $t1 = new Table('test');
     $c1 = new Column();
     $c1->setName('test');
     $c1->getDomain()->setType('INTEGER');
     $c1->setDefaultValue(0);
     $t1->addColumn($c1);
     $t2 = new Table('test');
     $c2 = new Column();
     $c2->setName('test');
     $c2->getDomain()->setType('INTEGER');
     $t2->addColumn($c2);
     return array(array(PropelColumnComparator::computeDiff($c1, $c2)));
 }
开发者ID:RafalFilipek,项目名称:Propel2,代码行数:15,代码来源:PlatformMigrationTestProvider.php

示例8: testGetIndexDDLFulltext

 public function testGetIndexDDLFulltext()
 {
     $table = new Table('foo');
     $table->setIdentifierQuoting(true);
     $column1 = new Column('bar1');
     $column1->getDomain()->copy($this->getPlatform()->getDomainForType('LONGVARCHAR'));
     $table->addColumn($column1);
     $index = new Index('bar_index');
     $index->addColumn($column1);
     $vendor = new VendorInfo('mysql');
     $vendor->setParameter('Index_type', 'FULLTEXT');
     $index->addVendorInfo($vendor);
     $table->addIndex($index);
     $expected = 'FULLTEXT INDEX `bar_index` (`bar1`)';
     $this->assertEquals($expected, $this->getPlatform()->getIndexDDL($index));
 }
开发者ID:SwissalpS,项目名称:Propel2,代码行数:16,代码来源:MysqlPlatformMyISAMTest.php

示例9: providerForTestGetForeignKeysDDL

 public function providerForTestGetForeignKeysDDL()
 {
     $db = new Database();
     $db->setIdentifierQuoting(true);
     $table1 = new Table('foo');
     $db->addTable($table1);
     $column1 = new Column('bar_id');
     $column1->getDomain()->copy(new Domain('FOOTYPE'));
     $table1->addColumn($column1);
     $table2 = new Table('bar');
     $db->addTable($table2);
     $column2 = new Column('id');
     $column2->getDomain()->copy(new Domain('BARTYPE'));
     $table2->addColumn($column2);
     $fk = new ForeignKey('foo_bar_fk');
     $fk->setForeignTableCommonName('bar');
     $fk->addReference($column1, $column2);
     $fk->setOnDelete('CASCADE');
     $table1->addForeignKey($fk);
     $column3 = new Column('baz_id');
     $column3->getDomain()->copy(new Domain('BAZTYPE'));
     $table1->addColumn($column3);
     $table3 = new Table('baz');
     $db->addTable($table3);
     $column4 = new Column('id');
     $column4->getDomain()->copy(new Domain('BAZTYPE'));
     $table3->addColumn($column4);
     $fk = new ForeignKey('foo_baz_fk');
     $fk->setForeignTableCommonName('baz');
     $fk->addReference($column3, $column4);
     $fk->setOnDelete('SETNULL');
     $table1->addForeignKey($fk);
     return array(array($table1));
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:34,代码来源:PlatformTestProvider.php

示例10: getUsingCast

 public function getUsingCast(Column $fromColumn, Column $toColumn)
 {
     $fromSqlType = strtoupper($fromColumn->getDomain()->getSqlType());
     $toSqlType = strtoupper($toColumn->getDomain()->getSqlType());
     $name = $fromColumn->getName();
     if ($this->isNumber($fromSqlType) && $this->isString($toSqlType)) {
         //cast from int to string
         return '  ';
     }
     if ($this->isString($fromSqlType) && $this->isNumber($toSqlType)) {
         //cast from string to int
         return "\n   USING CASE WHEN trim({$name}) SIMILAR TO '[0-9]+'\n        THEN CAST(trim({$name}) AS integer)\n        ELSE NULL END";
     }
     if ($this->isNumber($fromSqlType) && 'BYTEA' === $toSqlType) {
         return " USING decode(CAST({$name} as text), 'escape')";
     }
     if ('DATE' === $fromSqlType && 'TIME' === $toSqlType) {
         return " USING NULL";
     }
     if ($this->isNumber($fromSqlType) && $this->isNumber($toSqlType)) {
         return '';
     }
     if ($this->isString($fromSqlType) && $this->isString($toSqlType)) {
         return '';
     }
     return " USING NULL";
 }
开发者ID:disider,项目名称:Propel2,代码行数:27,代码来源:PgsqlPlatform.php

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

示例12: addColumns

 /**
  * Adds Columns to the specified table.
  *
  * @param      Table $table The Table model class to add columns to.
  * @param      int $oid The table OID
  * @param      string $version The database version.
  */
 protected function addColumns(Table $table, $oid, $version)
 {
     // Get the columns, types, etc.
     // Based on code from pgAdmin3 (http://www.pgadmin.org/)
     $stmt = $this->dbh->prepare("SELECT\n                                        att.attname,\n                                        att.atttypmod,\n                                        att.atthasdef,\n                                        att.attnotnull,\n                                        def.adsrc,\n                                        CASE WHEN att.attndims > 0 THEN 1 ELSE 0 END AS isarray,\n                                        CASE\n                                            WHEN ty.typname = 'bpchar'\n                                                THEN 'char'\n                                            WHEN ty.typname = '_bpchar'\n                                                THEN '_char'\n                                            ELSE\n                                                ty.typname\n                                        END AS typname,\n                                        ty.typtype\n                                    FROM pg_attribute att\n                                        JOIN pg_type ty ON ty.oid=att.atttypid\n                                        LEFT OUTER JOIN pg_attrdef def ON adrelid=att.attrelid AND adnum=att.attnum\n                                    WHERE att.attrelid = ? AND att.attnum > 0\n                                        AND att.attisdropped IS FALSE\n                                    ORDER BY att.attnum");
     $stmt->bindValue(1, $oid, PDO::PARAM_INT);
     $stmt->execute();
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $size = null;
         $precision = null;
         $scale = null;
         // Check to ensure that this column isn't an array data type
         if ((int) $row['isarray'] === 1) {
             throw new EngineException(sprintf("Array datatypes are not currently supported [%s.%s]", $this->name, $row['attname']));
         }
         // if (((int) $row['isarray']) === 1)
         $name = $row['attname'];
         // If they type is a domain, Process it
         if (strtolower($row['typtype']) == 'd') {
             $arrDomain = $this->processDomain($row['typname']);
             $type = $arrDomain['type'];
             $size = $arrDomain['length'];
             $precision = $size;
             $scale = $arrDomain['scale'];
             $boolHasDefault = strlen(trim($row['atthasdef'])) > 0 ? $row['atthasdef'] : $arrDomain['hasdefault'];
             $default = strlen(trim($row['adsrc'])) > 0 ? $row['adsrc'] : $arrDomain['default'];
             $isNullable = strlen(trim($row['attnotnull'])) > 0 ? $row['attnotnull'] : $arrDomain['notnull'];
             $isNullable = $isNullable == 't' ? false : true;
         } else {
             $type = $row['typname'];
             $arrLengthPrecision = $this->processLengthScale($row['atttypmod'], $type);
             $size = $arrLengthPrecision['length'];
             $precision = $size;
             $scale = $arrLengthPrecision['scale'];
             $boolHasDefault = $row['atthasdef'];
             $default = $row['adsrc'];
             $isNullable = $row['attnotnull'] == 't' ? false : true;
         }
         // else (strtolower ($row['typtype']) == 'd')
         $autoincrement = null;
         // if column has a default
         if ($boolHasDefault == 't' && strlen(trim($default)) > 0) {
             if (!preg_match('/^nextval\\(/', $default)) {
                 $strDefault = preg_replace('/::[\\W\\D]*/', '', $default);
                 $default = preg_replace('/(\'?)\'/', '${1}', $strDefault);
             } else {
                 $autoincrement = true;
                 $default = null;
             }
         } else {
             $default = null;
         }
         $propelType = $this->getMappedPropelType($type);
         if (!$propelType) {
             $propelType = Column::DEFAULT_TYPE;
             $this->warn("Column [" . $table->getName() . "." . $name . "] has a column type (" . $type . ") that Propel does not support.");
         }
         $column = new Column($name);
         $column->setTable($table);
         $column->setDomainForType($propelType);
         // We may want to provide an option to include this:
         // $column->getDomain()->replaceSqlType($type);
         $column->getDomain()->replaceSize($size);
         $column->getDomain()->replaceScale($scale);
         if ($default !== null) {
             if (in_array($default, array('now()'))) {
                 $type = ColumnDefaultValue::TYPE_EXPR;
             } else {
                 $type = ColumnDefaultValue::TYPE_VALUE;
             }
             $column->getDomain()->setDefaultValue(new ColumnDefaultValue($default, $type));
         }
         $column->setAutoIncrement($autoincrement);
         $column->setNotNull(!$isNullable);
         $table->addColumn($column);
     }
 }
开发者ID:rozwell,项目名称:Propel2,代码行数:84,代码来源:PgsqlSchemaParser.php

示例13: testCompareSeveralRenamedSamePrimaryKeys

 public function testCompareSeveralRenamedSamePrimaryKeys()
 {
     $t1 = new Table();
     $c1 = new Column('col1');
     $c1->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
     $c1->setNotNull(true);
     $c1->setPrimaryKey(true);
     $t1->addColumn($c1);
     $c2 = new Column('col2');
     $c2->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
     $c2->setNotNull(true);
     $c2->setPrimaryKey(true);
     $t1->addColumn($c2);
     $c3 = new Column('col3');
     $c3->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
     $c3->setNotNull(true);
     $c3->setPrimaryKey(true);
     $t1->addColumn($c3);
     $t2 = new Table();
     $c4 = new Column('col4');
     $c4->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
     $c4->setNotNull(true);
     $c4->setPrimaryKey(true);
     $t2->addColumn($c4);
     $c5 = new Column('col5');
     $c5->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
     $c5->setNotNull(true);
     $c5->setPrimaryKey(true);
     $t2->addColumn($c5);
     $c6 = new Column('col3');
     $c6->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
     $c6->setNotNull(true);
     $c6->setPrimaryKey(true);
     $t2->addColumn($c6);
     // col1 and col2 were renamed
     $tc = new TableComparator();
     $tc->setFromTable($t1);
     $tc->setToTable($t2);
     $nbDiffs = $tc->comparePrimaryKeys();
     $tableDiff = $tc->getTableDiff();
     $this->assertEquals(2, $nbDiffs);
     $this->assertEquals([[$c1, $c4], [$c2, $c5]], $tableDiff->getRenamedPkColumns());
     $this->assertEquals([], $tableDiff->getAddedPkColumns());
     $this->assertEquals([], $tableDiff->getRemovedPkColumns());
 }
开发者ID:disider,项目名称:Propel2,代码行数:45,代码来源:PropelTablePkColumnComparatorTest.php

示例14: testCompareMultipleDifferences

 public function testCompareMultipleDifferences()
 {
     $c1 = new Column();
     $c1->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
     $c1->setNotNull(false);
     $c2 = new Column();
     $c2->getDomain()->copy($this->platform->getDomainForType('DOUBLE'));
     $c2->getDomain()->replaceScale(2);
     $c2->getDomain()->replaceSize(3);
     $c2->setNotNull(true);
     $c2->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE));
     $expectedChangedProperties = array('type' => array('INTEGER', 'DOUBLE'), 'sqlType' => array('INTEGER', 'DOUBLE'), 'scale' => array(NULL, 2), 'size' => array(NULL, 3), 'notNull' => array(false, true), 'defaultValueType' => array(NULL, ColumnDefaultValue::TYPE_VALUE), 'defaultValueValue' => array(NULL, 123));
     $this->assertEquals($expectedChangedProperties, ColumnComparator::compareColumns($c1, $c2));
 }
开发者ID:rouffj,项目名称:Propel2,代码行数:14,代码来源:ColumnComparatorTest.php

示例15: getColumnDDL

 /**
  * Builds the DDL SQL for a Column object.
  * @return string
  */
 public function getColumnDDL(Column $col)
 {
     $domain = $col->getDomain();
     $ddl = array($this->quoteIdentifier($col->getName()));
     $sqlType = $domain->getSqlType();
     if ($this->hasSize($sqlType) && $col->isDefaultSqlType($this)) {
         $ddl[] = $sqlType . $col->getSizeDefinition();
     } else {
         $ddl[] = $sqlType;
     }
     if ($default = $this->getColumnDefaultValueDDL($col)) {
         $ddl[] = $default;
     }
     if ($notNull = $this->getNullString($col->isNotNull())) {
         $ddl[] = $notNull;
     }
     if ($autoIncrement = $col->getAutoIncrementString()) {
         $ddl[] = $autoIncrement;
     }
     return implode(' ', $ddl);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:25,代码来源:DefaultPlatform.php


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