本文整理匯總了PHP中DBManager::get_indices方法的典型用法代碼示例。如果您正苦於以下問題:PHP DBManager::get_indices方法的具體用法?PHP DBManager::get_indices怎麽用?PHP DBManager::get_indices使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DBManager
的用法示例。
在下文中一共展示了DBManager::get_indices方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testGetIndicesContainsPrimary
public function testGetIndicesContainsPrimary()
{
$indices = $this->_db->get_indices('accounts');
// find if any are primary
$found = false;
foreach ($indices as $index) {
if ($index['type'] == "primary") {
$found = true;
break;
}
}
$this->assertTrue($found, 'Primary Key Not Found On Module');
}
示例2: testRemovePrimaryKey
/**
* @depends testAddPrimaryKey
*/
public function testRemovePrimaryKey()
{
$tablename = 'testConstraints';
$this->created[$tablename] = true;
$sql = $this->_db->add_drop_constraint($tablename, array('name' => 'testConstraints_pk', 'type' => 'primary', 'fields' => array('id')), true);
$result = $this->_db->query($sql);
$indices = $this->_db->get_indices($tablename);
// find if any are primary
$found = false;
foreach ($indices as $index) {
if ($index['type'] == "primary") {
$found = true;
break;
}
}
$this->assertFalse($found, 'Primary Key Found On Table');
}
示例3: testRepairTableParamsAddIndexAndData
public function testRepairTableParamsAddIndexAndData()
{
$tableName = 'test1_' . mt_rand();
$params = array('foo' => array('name' => 'foo', 'type' => 'varchar', 'len' => '255'), 'bar' => array('name' => 'bar', 'type' => 'int'));
$index = array('name' => 'test_index', 'type' => 'index', 'fields' => array('foo', 'bar'));
if ($this->_db->tableExists($tableName)) {
$this->_db->dropTableName($tableName);
}
$this->createTableParams($tableName, $params, array());
$repair = $this->_db->repairTableParams($tableName, $params, array($index), false);
$this->assertRegExp('#MISSING INDEX IN DATABASE.*test_index#i', $repair);
$repair = $this->_db->repairTableParams($tableName, $params, array($index), true);
$idx = $this->_db->get_indices($tableName);
$this->assertArrayHasKey('test_index', $idx);
$this->assertContains('foo', $idx['test_index']['fields']);
$this->assertContains('bar', $idx['test_index']['fields']);
$this->dropTableName($tableName);
}