本文整理汇总了PHP中Mage_Core_Model_Resource_Setup::getIdxName方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Resource_Setup::getIdxName方法的具体用法?PHP Mage_Core_Model_Resource_Setup::getIdxName怎么用?PHP Mage_Core_Model_Resource_Setup::getIdxName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Model_Resource_Setup
的用法示例。
在下文中一共展示了Mage_Core_Model_Resource_Setup::getIdxName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
$installer = new Mage_Core_Model_Resource_Setup(Mage_Core_Model_Resource_Setup::DEFAULT_SETUP_CONNECTION);
$this->_connection = $installer->getConnection();
$this->_tableName = $installer->getTable('table_two_column_idx');
$this->_oneColumnIdxName = $installer->getIdxName($this->_tableName, array('column1'));
$this->_twoColumnIdxName = $installer->getIdxName($this->_tableName, array('column1', 'column2'));
$table = $this->_connection->newTable($this->_tableName)->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), 'Id')->addColumn('column1', Varien_Db_Ddl_Table::TYPE_INTEGER)->addColumn('column2', Varien_Db_Ddl_Table::TYPE_INTEGER)->addIndex($this->_oneColumnIdxName, array('column1'))->addIndex($this->_twoColumnIdxName, array('column1', 'column2'));
$this->_connection->createTable($table);
}
示例2: replaceUniqueKey
/**
* Replace unique key
*
* @param Mage_Core_Model_Resource_Setup $setup
* @param string $tableName
* @param string $keyName
* @param array $keyAttributes
* @return Innoexts_InnoCore_Helper_Database
*/
public function replaceUniqueKey($setup, $tableName, $keyName, $keyAttributes)
{
$connection = $setup->getConnection();
$versionHelper = $this->getVersionHelper();
$table = $setup->getTable($tableName);
if ($versionHelper->isGe1600()) {
$indexTypeUnique = Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE;
$indexes = $connection->getIndexList($table);
foreach ($indexes as $index) {
if ($index['INDEX_TYPE'] == $indexTypeUnique) {
$connection->dropIndex($table, $index['KEY_NAME']);
}
}
$keyName = $setup->getIdxName($tableName, $keyAttributes, $indexTypeUnique);
$connection->addIndex($table, $keyName, $keyAttributes, $indexTypeUnique);
} else {
$connection->addKey($table, $keyName, $keyAttributes, 'unique');
}
return $this;
}