本文整理匯總了PHP中DbHelper::getIndexName方法的典型用法代碼示例。如果您正苦於以下問題:PHP DbHelper::getIndexName方法的具體用法?PHP DbHelper::getIndexName怎麽用?PHP DbHelper::getIndexName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DbHelper
的用法示例。
在下文中一共展示了DbHelper::getIndexName方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: safeUp
/**
* Any migration code in here is wrapped inside of a transaction.
*
* @return bool
*/
public function safeUp()
{
if (!craft()->db->tableExists('searchindex')) {
// Taking the scenic route here so we can get to MysqlSchema's $engine argument
$table = DbHelper::addTablePrefix('searchindex');
$columns = array('elementId' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Int, 'null' => false)), 'attribute' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Varchar, 'maxLength' => 25, 'null' => false)), 'fieldId' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Int, 'null' => false)), 'locale' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Locale, 'null' => false)), 'keywords' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Text, 'null' => false)));
$this->execute(craft()->db->getSchema()->createTable($table, $columns, null, 'MyISAM'));
// Give it a composite primary key
$this->addPrimaryKey('searchindex', 'elementId,attribute,fieldId,locale');
// Add the FULLTEXT index on `keywords`
$this->execute('CREATE FULLTEXT INDEX ' . craft()->db->quoteTableName(DbHelper::getIndexName('searchindex', 'keywords')) . ' ON ' . craft()->db->quoteTableName($table) . ' ' . '(' . craft()->db->quoteColumnName('keywords') . ')');
Craft::log('Successfully added the `searchindex` table with a fulltext index on `keywords`.', LogLevel::Info, true);
} else {
Craft::log('Tried to add the `searchindex` table, but it already exists.', LogLevel::Warning, true);
}
return true;
}
示例2: _createSearchIndexTable
/**
* Creates the searchindex table.
*
* @access private
*/
private function _createSearchIndexTable()
{
Craft::log('Creating the searchindex table.');
// Taking the scenic route here so we can get to MysqlSchema's $engine argument
$table = DbHelper::addTablePrefix('searchindex');
$columns = array('elementId' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Int, 'null' => false)), 'attribute' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Varchar, 'maxLength' => 25, 'null' => false)), 'fieldId' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Int, 'null' => false)), 'locale' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Locale, 'null' => false)), 'keywords' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Text, 'null' => false)));
craft()->db->createCommand()->setText(craft()->db->getSchema()->createTable($table, $columns, null, 'MyISAM'))->execute();
// Give it a composite primary key
craft()->db->createCommand()->addPrimaryKey('searchindex', 'elementId,attribute,fieldId,locale');
// Add the FULLTEXT index on `keywords`
craft()->db->createCommand()->setText('CREATE FULLTEXT INDEX ' . craft()->db->quoteTableName(DbHelper::getIndexName('searchindex', 'keywords')) . ' ON ' . craft()->db->quoteTableName($table) . ' ' . '(' . craft()->db->quoteColumnName('keywords') . ')')->execute();
Craft::log('Finished creating the searchindex table.');
}
示例3: _restoreIndex
/**
* Restores an index.
*
* @static
* @access private
* @param object $fk
*/
private static function _restoreIndex($index)
{
craft()->db->createCommand()->createIndex($index->table->name, implode(',', $index->columns), $index->unique);
// Update our record of its name
$index->name = DbHelper::getIndexName($index->table->name, $index->columns, $index->unique);
}
示例4: dropIndex
/**
* @param string $table
* @param string $columns
* $param $unique
* @param bool $unique
* @return int
*/
public function dropIndex($table, $columns, $unique = false)
{
$name = DbHelper::getIndexName($table, $columns, $unique);
$table = DbHelper::addTablePrefix($table);
return parent::dropIndex($name, $table);
}