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


PHP Column::setNotNull方法代码示例

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


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

示例1: setColumns

 /**
  * Creates the column from a given array
  *
  * @param array $columns
  */
 public function setColumns($columns)
 {
     if (false == is_array($columns)) {
         return;
     }
     foreach ($columns as $name => $options) {
         $column = new Column();
         $type = $this->getOptionByKey("type", $options);
         $length = $this->getOptionByKey("length", $options);
         $notNull = $this->getOptionByKey("notNull", $options);
         $autoIncrement = $this->getOptionByKey("autoIncrement", $options);
         $index = $this->getOptionByKey("index", $options);
         $collate = $this->getOptionByKey("collate", $options);
         $column->setName($name);
         // Set all options if set
         if (false != $type) {
             $column->setType($type);
         }
         if (false != $length) {
             $column->setLength($length);
         }
         if (false != $notNull) {
             $column->setNotNull($notNull);
         }
         if (false != $autoIncrement) {
             $column->setAutoIncrement($autoIncrement);
         }
         if (false != $index) {
             $column->setIndex($index);
         }
         if (false != $collate) {
             $column->setCollate($collate);
         }
         // Add column
         $this->columns[] = $column;
     }
 }
开发者ID:fewlines,项目名称:component,代码行数:42,代码来源:Table.php

示例2: 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("SELECT COLUMN_NAME, DATA_TYPE, NULLABLE, DATA_LENGTH, DATA_PRECISION, DATA_SCALE, DATA_DEFAULT FROM USER_TAB_COLS WHERE TABLE_NAME = '" . $table->getName() . "'");
     /* @var stmt PDOStatement */
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         if (strpos($row['COLUMN_NAME'], '$') !== false) {
             // this is an Oracle internal column - prune
             continue;
         }
         $size = $row["DATA_PRECISION"] ? $row["DATA_PRECISION"] : $row["DATA_LENGTH"];
         $scale = $row["DATA_SCALE"];
         $default = $row['DATA_DEFAULT'];
         $type = $row["DATA_TYPE"];
         $isNullable = $row['NULLABLE'] == 'Y';
         if ($type == "NUMBER" && $row["DATA_SCALE"] > 0) {
             $type = "DECIMAL";
         }
         if ($type == "NUMBER" && $size > 9) {
             $type = "BIGINT";
         }
         if ($type == "FLOAT" && $row["DATA_PRECISION"] == 126) {
             $type = "DOUBLE";
         }
         if (strpos($type, 'TIMESTAMP(') !== false) {
             $type = substr($type, 0, strpos($type, '('));
             $default = "0000-00-00 00:00:00";
             $size = null;
             $scale = null;
         }
         if ($type == "DATE") {
             $default = "0000-00-00";
             $size = null;
             $scale = null;
         }
         $propelType = $this->getMappedPropelType($type);
         if (!$propelType) {
             $propelType = Column::DEFAULT_TYPE;
             $this->warn("Column [" . $table->getName() . "." . $row['COLUMN_NAME'] . "] has a column type (" . $row["DATA_TYPE"] . ") that Propel does not support.");
         }
         $column = new Column($row['COLUMN_NAME']);
         $column->setPhpName();
         // Prevent problems with strange col names
         $column->setTable($table);
         $column->setDomainForType($propelType);
         $column->getDomain()->replaceSize($size);
         $column->getDomain()->replaceScale($scale);
         if ($default !== null) {
             $column->getDomain()->setDefaultValue(new ColumnDefaultValue($default, ColumnDefaultValue::TYPE_VALUE));
         }
         $column->setAutoIncrement(false);
         // This flag sets in self::parse()
         $column->setNotNull(!$isNullable);
         $table->addColumn($column);
     }
 }
开发者ID:kcornejo,项目名称:estadistica,代码行数:60,代码来源:OracleSchemaParser.php

示例3: testGetColumnDDLCustomSqlType

 public function testGetColumnDDLCustomSqlType()
 {
     $column = new Column('foo');
     $column->getDomain()->copy($this->getPlatform()->getDomainForType('DOUBLE'));
     $column->getDomain()->replaceScale(2);
     $column->getDomain()->replaceSize(3);
     $column->setNotNull(true);
     $column->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE));
     $column->getDomain()->replaceSqlType('DECIMAL(5,6)');
     $expected = '`foo` DECIMAL(5,6) DEFAULT 123 NOT NULL';
     $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column));
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:12,代码来源:MysqlPlatformTest.php

示例4: 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("sp_columns '" . $table->getName() . "'");
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $name = $row['COLUMN_NAME'];
         $type = $row['TYPE_NAME'];
         $size = $row['LENGTH'];
         $is_nullable = $row['NULLABLE'];
         $default = $row['COLUMN_DEF'];
         $precision = $row['PRECISION'];
         $scale = $row['SCALE'];
         $autoincrement = false;
         if (strtolower($type) == "int identity") {
             $autoincrement = true;
         }
         $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) {
             $column->getDomain()->setDefaultValue(new ColumnDefaultValue($default, ColumnDefaultValue::TYPE_VALUE));
         }
         $column->setAutoIncrement($autoincrement);
         $column->setNotNull(!$is_nullable);
         $table->addColumn($column);
     }
 }
开发者ID:norfil,项目名称:Propel2,代码行数:40,代码来源:MssqlSchemaParser.php

示例5: testCompareModifiedIndices

 public function testCompareModifiedIndices()
 {
     $t1 = new Table();
     $c1 = new Column('Foo');
     $c1->getDomain()->copy($this->platform->getDomainForType('VARCHAR'));
     $c1->getDomain()->replaceSize(255);
     $c1->setNotNull(false);
     $t1->addColumn($c1);
     $i1 = new Index('Foo_Index');
     $i1->addColumn($c1);
     $t1->addIndex($i1);
     $t2 = new Table();
     $c2 = new Column('Foo');
     $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));
     $t2->addColumn($c2);
     $i2 = new Unique('Foo_Index');
     $i2->addColumn($c2);
     $t2->addIndex($i2);
     $tc = new PropelTableComparator();
     $tc->setFromTable($t1);
     $tc->setToTable($t2);
     $nbDiffs = $tc->compareIndices();
     $tableDiff = $tc->getTableDiff();
     $this->assertEquals(1, $nbDiffs);
     $this->assertEquals(1, count($tableDiff->getModifiedIndices()));
     $this->assertEquals(array('Foo_Index' => array($i1, $i2)), $tableDiff->getModifiedIndices());
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:31,代码来源:PropelTableIndexComparatorTest.php

示例6: 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;
     $desc = $row['Comment'];
     $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 && $scale === null) {
                 $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);
     }
     if ($desc) {
         if (!$this->isUtf8($desc)) {
             $desc = utf8_encode($desc);
//.........这里部分代码省略.........
开发者ID:thehereward,项目名称:Propel,代码行数:101,代码来源:MysqlSchemaParser.php

示例7: testGetColumnDDL

 public function testGetColumnDDL()
 {
     $c = new Column('foo');
     $c->getDomain()->copy($this->getPlatform()->getDomainForType('DOUBLE'));
     $c->getDomain()->replaceScale(2);
     $c->getDomain()->replaceSize(3);
     $c->setNotNull(true);
     $c->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE));
     $expected = '"foo" DOUBLE PRECISION DEFAULT 123 NOT NULL';
     $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($c));
 }
开发者ID:rubensayshi,项目名称:propelsandbox,代码行数:11,代码来源:PgsqlPlatformTest.php

示例8: 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("SHOW COLUMNS FROM `" . $table->getName() . "`");
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $name = $row['Field'];
         $is_nullable = $row['Null'] == 'YES';
         $autoincrement = strpos($row['Extra'], 'auto_increment') !== false;
         $size = null;
         $precision = null;
         $scale = null;
         if (preg_match('/^(\\w+)[\\(]?([\\d,]*)[\\)]?( |$)/', $row['Type'], $matches)) {
             //            colname[1]   size/precision[2]
             $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];
                 }
             }
         } elseif (preg_match('/^(\\w+)\\(/', $row['Type'], $matches)) {
             $nativeType = $matches[1];
         } 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;
             $this->warn("Column [" . $table->getName() . "." . $name . "] has a column type (" . $nativeType . ") 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) {
             $column->getDomain()->setDefaultValue(new ColumnDefaultValue($default, ColumnDefaultValue::TYPE_VALUE));
         }
         $column->setAutoIncrement($autoincrement);
         $column->setNotNull(!$is_nullable);
         if ($this->addVendorInfo) {
             $vi = $this->getNewVendorInfoObject($row);
             $column->addVendorInfo($vi);
         }
         $table->addColumn($column);
     }
 }
开发者ID:yasirgit,项目名称:afids,代码行数:58,代码来源:MysqlSchemaParser.php

示例9: 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 PropelTableComparator();
     $tc->setFromTable($t1);
     $tc->setToTable($t2);
     $nbDiffs = $tc->comparePrimaryKeys();
     $tableDiff = $tc->getTableDiff();
     $this->assertEquals(2, $nbDiffs);
     $this->assertEquals(array(array($c1, $c4), array($c2, $c5)), $tableDiff->getRenamedPkColumns());
     $this->assertEquals(array(), $tableDiff->getAddedPkColumns());
     $this->assertEquals(array(), $tableDiff->getRemovedPkColumns());
 }
开发者ID:thehereward,项目名称:Propel,代码行数:45,代码来源:PropelTablePkColumnComparatorTest.php

示例10: providerForTestGetModifyColumnsDDL

 public function providerForTestGetModifyColumnsDDL()
 {
     $t1 = new Table('foo');
     $c1 = new Column('bar1');
     $c1->getDomain()->copy($this->getPlatform()->getDomainForType('DOUBLE'));
     $c1->getDomain()->replaceSize(2);
     $t1->addColumn($c1);
     $c2 = new Column('bar2');
     $c2->getDomain()->setType('INTEGER');
     $c2->getDomain()->setSqlType('INTEGER');
     $t1->addColumn($c2);
     $t2 = new Table('foo');
     $c3 = new Column('bar1');
     $c3->getDomain()->copy($this->getPlatform()->getDomainForType('DOUBLE'));
     $c3->getDomain()->replaceSize(3);
     $t2->addColumn($c3);
     $c4 = new Column('bar2');
     $c4->getDomain()->setType('INTEGER');
     $c4->getDomain()->setSqlType('INTEGER');
     $c4->setNotNull(true);
     $t2->addColumn($c4);
     return array(array(array(PropelColumnComparator::computeDiff($c1, $c3), PropelColumnComparator::computeDiff($c2, $c4))));
 }
开发者ID:homer6,项目名称:Propel,代码行数:23,代码来源:PlatformMigrationTestProvider.php

示例11: 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);
         // 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:robin850,项目名称:Propel2,代码行数:39,代码来源:MssqlSchemaParser.php

示例12: 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:rubensayshi,项目名称:propelsandbox,代码行数:11,代码来源:MysqlPlatformTest.php

示例13: addColumns

 /**
  * Adds Columns to the specified table.
  *
  * @param      Table $table The Table model class to add columns to.
  */
 protected function addColumns(Table $table)
 {
     return;
     $stmt = $this->dbh->query("SHOW COLUMNS FROM `" . $table->getName() . "`");
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $row['Comment'] = $this->dbh->query("\n\t\t\t\tSELECT\n\t\t\t\tCOLUMN_COMMENT\n\t\t\t\tFROM information_schema.COLUMNS\n\t\t\t\tWHERE TABLE_NAME='{$table->getName()}'\n\t\t\t\t\tAND TABLE_SCHEMA='{$table->getDatabase()->getName()}'\n\t\t\t\t\tAND COLUMN_NAME='{$row['Field']}' LIMIT 1")->fetchColumn();
         $name = $row['Field'];
         $is_nullable = $row['Null'] == 'YES';
         $autoincrement = strpos($row['Extra'], 'auto_increment') !== false;
         $size = null;
         $precision = null;
         $scale = null;
         if (preg_match('/^(\\w+)[\\(]?([\\d,]*)[\\)]?( |$)/', $row['Type'], $matches)) {
             //            colname[1]   size/precision[2]
             $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];
                 }
             }
             foreach (self::$defaultTypeSizes as $type => $defaultSize) {
                 if ($nativeType == $type && $size == $defaultSize) {
                     $size = null;
                     continue;
                 }
             }
         } elseif (preg_match('/^(\\w+)\\(/', $row['Type'], $matches)) {
             $nativeType = $matches[1];
         } 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 (in_array($propelType, array(PropelTypes::INTEGER, PropelTypes::BIGINT)) && strpos($row['Comment'], 'timestamp') === 0) {
             $propelType = PropelTypes::INTEGER_TIMESTAMP;
         } elseif (!$propelType) {
             $propelType = Column::DEFAULT_TYPE;
             $this->warn("Column [" . $table->getName() . "." . $name . "] has a column type (" . $nativeType . ") 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 ($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);
         }
         $table->addColumn($column);
     }
 }
开发者ID:abcarroll,项目名称:DABL,代码行数:81,代码来源:AccessSchemaParser.php

示例14: testCompareSeveralColumnDifferences

 public function testCompareSeveralColumnDifferences()
 {
     $t1 = new Table();
     $c1 = new Column('col1');
     $c1->getDomain()->copy($this->platform->getDomainForType('VARCHAR'));
     $c1->getDomain()->replaceSize(255);
     $c1->setNotNull(false);
     $t1->addColumn($c1);
     $c2 = new Column('col2');
     $c2->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
     $c2->setNotNull(true);
     $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('col1');
     $c4->getDomain()->copy($this->platform->getDomainForType('DOUBLE'));
     $c4->getDomain()->replaceScale(2);
     $c4->getDomain()->replaceSize(3);
     $c4->setNotNull(true);
     $c4->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE));
     $t2->addColumn($c4);
     $c5 = new Column('col22');
     $c5->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
     $c5->setNotNull(true);
     $t2->addColumn($c5);
     $c6 = new Column('col4');
     $c6->getDomain()->copy($this->platform->getDomainForType('LONGVARCHAR'));
     $c6->getDomain()->setDefaultValue(new ColumnDefaultValue('123', ColumnDefaultValue::TYPE_VALUE));
     $t2->addColumn($c6);
     // col1 was modified, col2 was renamed, col3 was removed, col4 was added
     $tc = new PropelTableComparator();
     $tc->setFromTable($t1);
     $tc->setToTable($t2);
     $nbDiffs = $tc->compareColumns();
     $tableDiff = $tc->getTableDiff();
     $this->assertEquals(4, $nbDiffs);
     $this->assertEquals(array(array($c2, $c5)), $tableDiff->getRenamedColumns());
     $this->assertEquals(array('col4' => $c6), $tableDiff->getAddedColumns());
     $this->assertEquals(array('col3' => $c3), $tableDiff->getRemovedColumns());
     $columnDiff = PropelColumnComparator::computeDiff($c1, $c4);
     $this->assertEquals(array('col1' => $columnDiff), $tableDiff->getModifiedColumns());
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:45,代码来源:PropelTableColumnComparatorTest.php

示例15: 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, PropelColumnComparator::compareColumns($c1, $c2));
 }
开发者ID:kcornejo,项目名称:estadistica,代码行数:14,代码来源:PropelColumnComparatorTest.php


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