本文整理汇总了PHP中Propel\Generator\Model\Table::hasColumn方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::hasColumn方法的具体用法?PHP Table::hasColumn怎么用?PHP Table::hasColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Generator\Model\Table
的用法示例。
在下文中一共展示了Table::hasColumn方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addColumn
protected function addColumn(Table $table, $name)
{
if (!$table->hasColumn($name)) {
$column = new Column($name);
// don't know how to define unsigned :(
$domain = new Domain('TINYINT', 'tinyint(3) unsigned');
$column->setDomain($domain);
$table->addColumn($column);
$column_idx_name = $name . '_idx';
if (!$table->hasIndex($column_idx_name)) {
$column_idx = new Index($column_idx_name);
$column_idx->addColumn(['name' => $column->getName()]);
$table->addIndex($column_idx);
}
}
}
示例2: testCantGetColumn
public function testCantGetColumn()
{
$table = new Table('books');
$this->assertFalse($table->hasColumn('FOO', true));
$this->assertNull($table->getColumn('FOO'));
$this->assertNull($table->getColumnByPhpName('Foo'));
}
示例3: addIndexes
/**
* Adds Indexes to the specified table.
*
* @param Table $table The Table model class to add columns to.
*/
protected function addIndexes(Table $table)
{
$stmt = $this->dbh->query("SELECT COLUMN_NAME, INDEX_NAME FROM USER_IND_COLUMNS WHERE TABLE_NAME = '" . $table->getName() . "' ORDER BY COLUMN_NAME");
$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$indices = array();
foreach ($rows as $row) {
$indices[$row['INDEX_NAME']][] = $row['COLUMN_NAME'];
}
foreach ($indices as $indexName => $columnNames) {
$index = new Index($indexName);
foreach ($columnNames as $columnName) {
// Oracle deals with complex indices using an internal reference, so...
// let's ignore this kind of index
if ($table->hasColumn($columnName)) {
$index->addColumn($table->getColumn($columnName));
}
}
// since some of the columns are pruned above, we must only add an index if it has columns
if ($index->hasColumns()) {
$table->addIndex($index);
}
}
}
示例4: addLogColumns
protected function addLogColumns(Table $table)
{
if ('true' === $this->getParameter('created_at') && !$table->hasColumn($this->getParameter('created_at_column'))) {
$table->addColumn(array('name' => $this->getParameter('created_at_column'), 'type' => 'TIMESTAMP'));
}
if ('true' === $this->getParameter('created_by') && !$table->hasColumn($this->getParameter('created_by_column'))) {
$table->addColumn(array('name' => $this->getParameter('created_by_column'), 'type' => 'VARCHAR', 'size' => 100));
}
if ('true' === $this->getParameter('comment') && !$table->hasColumn($this->getParameter('comment_column'))) {
$table->addColumn(array('name' => $this->getParameter('comment_column'), 'type' => 'VARCHAR', 'size' => 255));
}
}