本文整理汇总了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);
}