本文整理汇总了PHP中DBManager::modifyIndexes方法的典型用法代码示例。如果您正苦于以下问题:PHP DBManager::modifyIndexes方法的具体用法?PHP DBManager::modifyIndexes怎么用?PHP DBManager::modifyIndexes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBManager
的用法示例。
在下文中一共展示了DBManager::modifyIndexes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testModifyMultiIndexesByMultiQuery
public function testModifyMultiIndexesByMultiQuery()
{
$tableName = 'test17_' . mt_rand();
$fields = array('foo' => array('name' => 'foo', 'type' => 'varchar', 'len' => '255'), 'bar' => array('name' => 'bar', 'type' => 'varchar', 'len' => '255'));
$indexes = array('idx_foo' => array('name' => 'idx_foo', 'type' => 'index', 'fields' => array('foo')), 'idx_bar' => array('name' => 'idx_bar', 'type' => 'index', 'fields' => array('bar')));
$this->createTableParams($tableName, $fields, $indexes);
$indexesDB = $this->_db->get_indices($tableName);
$this->assertEquals($indexes, $indexesDB, 'Indexes are incorrect');
$indexesNew = $indexes;
$indexesNew['idx_foo']['fields'] = array('bar');
$indexesNew['idx_bar']['fields'] = array('foo');
$queries = $this->_db->modifyIndexes($tableName, $indexesNew, false);
$queries = explode(";\n", rtrim(trim($queries), ';'));
$this->_db->query($queries);
$indexesDB = $this->_db->get_indices($tableName);
$this->assertEquals($indexesNew, $indexesDB, 'Indexes are incorrect');
}
示例2: testModifyIndexes
public function testModifyIndexes()
{
//TODO Fix test with normal index inspection
$this->markTestIncomplete('TODO Reimplement test not using compareIndexInTables.');
$tablename1 = 'test21_' . mt_rand();
$this->createTableParams($tablename1, array('foo' => array('name' => 'foo', 'type' => 'varchar', 'len' => '255'), 'foobar' => array('name' => 'foobar', 'type' => 'varchar', 'len' => '255')), array(array('name' => 'idx_' . $tablename1, 'type' => 'index', 'fields' => array('foo'))));
$tablename2 = 'test22_' . mt_rand();
$this->createTableParams($tablename2, array('foo' => array('name' => 'foo', 'type' => 'varchar', 'len' => '255'), 'foobar' => array('name' => 'foobar', 'type' => 'varchar', 'len' => '255')), array(array('name' => 'idx_' . $tablename2, 'type' => 'index', 'fields' => array('foobar'))));
$res = $this->_db->compareIndexInTables('idx_foo', $tablename1, $tablename2);
$this->assertEquals($res['msg'], 'no_match');
$this->_db->modifyIndexes($tablename2, array(array('name' => 'idx_foo', 'type' => 'index', 'fields' => array('foo'))), false);
$res = $this->_db->compareIndexInTables('idx_foo', $tablename1, $tablename2);
$this->assertEquals($res['msg'], 'no_match');
$this->_db->modifyIndexes($tablename2, array(array('name' => 'idx_foo', 'type' => 'index', 'fields' => array('foo'))));
$res = $this->_db->compareIndexInTables('idx_foo', $tablename1, $tablename2);
$this->assertEquals($res['msg'], 'match');
$this->dropTableName($tablename1);
$this->dropTableName($tablename2);
}