本文整理汇总了PHP中Propel\Generator\Model\Index::hasColumns方法的典型用法代码示例。如果您正苦于以下问题:PHP Index::hasColumns方法的具体用法?PHP Index::hasColumns怎么用?PHP Index::hasColumns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Generator\Model\Index
的用法示例。
在下文中一共展示了Index::hasColumns方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddIndexedColumns
/**
* @dataProvider provideColumnDefinitions
*
*/
public function testAddIndexedColumns($columns)
{
$index = new Index();
$index->setColumns($columns);
$this->assertTrue($index->hasColumns());
$this->assertCount(3, $index->getColumns());
$this->assertSame(100, $index->getColumnSize('foo'));
$this->assertTrue($index->hasColumnSize('foo'));
$this->assertSame(5, $index->getColumnSize('bar'));
$this->assertTrue($index->hasColumnSize('bar'));
$this->assertNull($index->getColumnSize('baz'));
}
示例2: 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);
}
}
}