本文整理汇总了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);
}
}
示例2: testSetCustomPhpName
public function testSetCustomPhpName()
{
$column = new Column('created_at');
$column->setPhpName('CreatedAt');
$this->assertSame('CreatedAt', $column->getPhpName());
$this->assertSame('createdAt', $column->getStudlyPhpName());
}
示例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');
}
示例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());
}