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


PHP Column::setDefaultValue方法代码示例

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


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

示例1: createEnumColumn

 public function createEnumColumn($defaultValues, $defaultValue)
 {
     $column = new Column();
     $column->setType(PropelTypes::ENUM);
     $column->setValueSet($defaultValues);
     $column->setDefaultValue($defaultValue);
     return $column;
 }
开发者ID:RafalFilipek,项目名称:Propel2,代码行数:8,代码来源:DefaultPlatformTest.php

示例2: getDefaultValueStringProvider

 public static function getDefaultValueStringProvider()
 {
     $col1 = new Column('Bar');
     $col1->setDomain(new Domain('VARCHAR'));
     $col1->setDefaultValue(new ColumnDefaultValue('abc', ColumnDefaultValue::TYPE_VALUE));
     $val1 = "'abc'";
     $col2 = new Column('Bar');
     $col2->setDomain(new Domain('INTEGER'));
     $col2->setDefaultValue(new ColumnDefaultValue(1234, ColumnDefaultValue::TYPE_VALUE));
     $val2 = "1234";
     $col3 = new Column('Bar');
     $col3->setDomain(new Domain('DATE'));
     $col3->setDefaultValue(new ColumnDefaultValue('0000-00-00', ColumnDefaultValue::TYPE_VALUE));
     $val3 = "NULL";
     return array(array($col1, $val1), array($col2, $val2), array($col3, $val3));
 }
开发者ID:robin850,项目名称:Propel2,代码行数:16,代码来源:ObjectBuilderTest.php

示例3: providerForTestGetModifyColumnRemoveDefaultValueDDL

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

示例4: getColumnDDL

 public function getColumnDDL(Column $col)
 {
     if ($col->isAutoIncrement()) {
         $col->setType('INTEGER');
         $col->setDomainForType('INTEGER');
     }
     if ($col->getDefaultValue() && $col->getDefaultValue()->isExpression() && 'CURRENT_TIMESTAMP' === $col->getDefaultValue()->getValue()) {
         //sqlite use CURRENT_TIMESTAMP different than mysql/pgsql etc
         //we set it to the more common behavior
         $col->setDefaultValue(new ColumnDefaultValue("(datetime(CURRENT_TIMESTAMP, 'localtime'))", ColumnDefaultValue::TYPE_EXPR));
     }
     return parent::getColumnDDL($col);
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:13,代码来源:SqlitePlatform.php

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

示例6: Column

$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');
$fkCategoryPost->setPhpName('Category');
$fkCategoryPost->setDefaultJoin('Criteria::INNER_JOIN');
$fkCategoryPost->setOnDelete('SETNULL');
开发者ID:disider,项目名称:Propel2,代码行数:31,代码来源:blog-database.php

示例7: createMigrationTable

 public function createMigrationTable($datasource)
 {
     $platform = $this->getPlatform($datasource);
     // modelize the table
     $database = new Database($datasource);
     $database->setPlatform($platform);
     $table = new Table($this->getMigrationTable());
     $database->addTable($table);
     $column = new Column('version');
     $column->getDomain()->copy($platform->getDomainForType('INTEGER'));
     $column->setDefaultValue(0);
     $table->addColumn($column);
     // insert the table into the database
     $statements = $platform->getAddTableDDL($table);
     $conn = $this->getAdapterConnection($datasource);
     $res = SqlParser::executeString($statements, $conn);
     if (!$res) {
         throw new \Exception(sprintf('Unable to create migration table in datasource "%s"', $datasource));
     }
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:20,代码来源:MigrationManager.php

示例8: testGetDefaultValueString

 /**
  * @dataProvider provideDefaultValues
  */
 public function testGetDefaultValueString($mappingType, $value, $expected)
 {
     $defaultValue = $this->getMockBuilder('Propel\\Generator\\Model\\ColumnDefaultValue')->disableOriginalConstructor()->getMock();
     $defaultValue->expects($this->any())->method('getValue')->will($this->returnValue($value));
     $domain = $this->getDomainMock();
     $domain->expects($this->any())->method('getDefaultValue')->will($this->returnValue($defaultValue));
     $domain->expects($this->any())->method('setDefaultValue');
     $domain->expects($this->any())->method('getType')->will($this->returnValue($mappingType));
     $column = new Column();
     $column->setDomain($domain);
     $column->setDefaultValue('foo');
     // Test with a scalar
     $column->setDefaultValue($defaultValue);
     // Test with an object
     $this->assertSame($expected, $column->getDefaultValueString());
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:19,代码来源:ColumnTest.php


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