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


PHP Column::setPhpName方法代码示例

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


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

示例1: 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() . "'");
     while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
         if (false !== strpos($row['COLUMN_NAME'], '$')) {
             // 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 = 'Y' === $row['NULLABLE'];
         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 (false !== strpos($type, 'TIMESTAMP(')) {
             $type = substr($type, 0, strpos($type, '('));
             $default = '0000-00-00 00:00:00';
             $size = null;
             $scale = null;
         }
         if ('DATE' === $type) {
             $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()->setOriginSqlType($type);
         $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:bondarovich,项目名称:Propel2,代码行数:60,代码来源:OracleSchemaParser.php

示例2: testSetCustomPhpName

 public function testSetCustomPhpName()
 {
     $column = new Column('created_at');
     $column->setPhpName('CreatedAt');
     $this->assertSame('CreatedAt', $column->getPhpName());
     $this->assertSame('createdAt', $column->getStudlyPhpName());
 }
开发者ID:robin850,项目名称:Propel2,代码行数:7,代码来源:ColumnTest.php

示例3: testPhpSingularName

 public function testPhpSingularName()
 {
     $column = new Column();
     $column->setPhpName('Aliases');
     $this->assertEquals($column->getPhpName(), 'Aliases');
     $this->assertEquals($column->getPhpSingularName(), 'Aliase');
     $column = new Column();
     $column->setPhpName('Aliases');
     $column->setPhpSingularName('Alias');
     $this->assertEquals($column->getPhpName(), 'Aliases');
     $this->assertEquals($column->getPhpSingularName(), 'Alias');
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:12,代码来源:ColumnTest.php

示例4: testValidateReturnsFalseWhenTwoColumnssHaveSamePhpName

 public function testValidateReturnsFalseWhenTwoColumnssHaveSamePhpName()
 {
     $column1 = new Column('foo');
     $column2 = new Column('bar');
     $column2->setPhpName('Foo');
     $table = new Table('foo_table');
     $table->addColumn($column1);
     $table->addColumn($column2);
     $appData = $this->getAppDataForTable($table);
     $validator = new SchemaValidator($appData);
     $this->assertFalse($validator->validate());
     $this->assertContains('Column "bar" declares a phpName already used in table "foo_table"', $validator->getErrors());
 }
开发者ID:rouffj,项目名称:Propel2,代码行数:13,代码来源:SchemaValidatorTest.php


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