本文整理汇总了PHP中DBManager::tableExists方法的典型用法代码示例。如果您正苦于以下问题:PHP DBManager::tableExists方法的具体用法?PHP DBManager::tableExists怎么用?PHP DBManager::tableExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBManager
的用法示例。
在下文中一共展示了DBManager::tableExists方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetTablesArray
public function testGetTablesArray()
{
$tablename = 'test' . mt_rand();
$this->createTableParams($tablename, array('foo' => array('name' => 'foo', 'type' => 'varchar', 'len' => '255')), array());
$this->assertTrue($this->_db->tableExists($tablename));
$this->dropTableName($tablename);
}
示例2: createCustomTable
/**
* Creates the custom table with an id of id_c.
*
* @param bool $execute
* @return string
*/
public function createCustomTable($execute = true)
{
$out = '';
if (!$this->db->tableExists($this->bean->table_name . '_cstm')) {
$GLOBALS['log']->debug('creating custom table for ' . $this->bean->table_name);
$idDef = array('id_c' => array('name' => 'id_c', 'type' => 'id', 'required' => 1));
$idIdx = array('id' => array('name' => $this->bean->table_name . '_cstm_pk', 'type' => 'primary', 'fields' => array('id_c')));
$query = $this->db->createTableSQLParams($this->bean->table_name . '_cstm', $idDef, $idIdx);
if (!$this->db->supports('inline_keys')) {
$indicesArr = $this->db->getConstraintSql($idIdx, $this->bean->table_name . '_cstm');
} else {
$indicesArr = array();
}
if ($execute) {
$this->db->query($query);
if (!empty($indicesArr)) {
foreach ($indicesArr as $idxq) {
$this->db->query($idxq);
}
}
}
$out = $query . "\n";
if (!empty($indicesArr)) {
$out .= implode("\n", $indicesArr) . "\n";
}
$out .= $this->add_existing_custom_fields($execute);
}
return $out;
}
示例3:
/**
* Delete the primary table for the module implementing the class.
* If custom fields were added to this table/module, the custom table will be removed too, along with the cache
* entries that define the custom fields.
*
*/
function drop_tables()
{
global $dictionary;
$key = $this->getObjectName();
if (!array_key_exists($key, $dictionary)) {
$GLOBALS['log']->fatal("drop_tables: Metadata for table " . $this->table_name . " does not exist");
echo "meta data absent for table " . $this->table_name . "<br>\n";
} else {
if (empty($this->table_name)) {
return;
}
if ($this->db->tableExists($this->table_name)) {
$this->db->dropTable($this);
}
if ($this->db->tableExists($this->table_name . '_cstm')) {
$this->db->dropTableName($this->table_name . '_cstm');
DynamicField::deleteCache();
}
if ($this->db->tableExists($this->get_audit_table_name())) {
$this->db->dropTableName($this->get_audit_table_name());
}
}
}
示例4: preflightDB
/**
* Check that DB settings are fine
* @return bool
*/
protected function preflightDB()
{
$check = $this->db->canInstall();
if ($check !== true) {
$error = array_shift($check);
array_unshift($check, $this->translate($error));
return $this->error(call_user_func_array('sprintf', $check), true);
}
$tablename = "uptest" . uniqid();
if (!$this->db->query("CREATE TABLE {$tablename}(a int, b int)")) {
$fail = "Table creation";
} elseif (!$this->db->query("INSERT INTO {$tablename}(a,b) VALUES(1,2)")) {
$fail = "Insertion";
} elseif (!$this->db->query("UPDATE {$tablename} SET a=2 WHERE a=1")) {
$fail = "Update";
} elseif (!$this->db->query("DELETE FROM {$tablename} WHERE a=2")) {
$fail = "Deletion";
}
if ($this->db->tableExists($tablename)) {
if (!$this->db->query("DROP TABLE {$tablename}") && empty($fail)) {
$fail = "Table deletion";
}
}
if (!empty($fail)) {
return $this->error("{$fail} test failed, please check DB permissions.", true);
}
return true;
}