本文整理汇总了PHP中DBManager::createTableSQLParams方法的典型用法代码示例。如果您正苦于以下问题:PHP DBManager::createTableSQLParams方法的具体用法?PHP DBManager::createTableSQLParams怎么用?PHP DBManager::createTableSQLParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBManager
的用法示例。
在下文中一共展示了DBManager::createTableSQLParams方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: testModifyIndexByMultiQuery
public function testModifyIndexByMultiQuery()
{
$tableName = 'test24_' . mt_rand();
$this->created[$tableName] = true;
$fields = array('foo' => array('name' => 'foo', 'type' => 'varchar', 'len' => '255'), 'foobar' => array('name' => 'foobar', 'type' => 'varchar', 'len' => '255'));
$indexes = array();
$queries = array();
$queries[] = $this->_db->createTableSQLParams($tableName, $fields, $indexes);
$indexes = array('idx_foo' => array('name' => 'idx_foo', 'type' => 'index', 'fields' => array('foo')));
$tQueries = $this->_db->addIndexes($tableName, $indexes, false);
$queries = array_merge($queries, explode(";\n", rtrim($tQueries, ";\n")));
$indexesNew = $indexes;
$indexesNew['idx_foo']['fields'] = array('foobar');
$tQueries = $this->_db->modifyIndexes($tableName, $indexesNew, false);
$queries = array_merge($queries, explode(";\n", rtrim($tQueries, ";\n")));
$this->_db->query($queries);
$indexesDB = $this->_db->get_indices($tableName);
$this->assertEquals($indexesNew, $indexesDB, 'Indexes are incorrect');
}
示例3: strtolower
/**
* If auditing is enabled, create the audit table.
*
* Function is used by the install scripts and a repair utility in the admin panel.
*
* Internal function, do not override.
*/
function create_audit_table()
{
global $dictionary;
$table_name = $this->get_audit_table_name();
require 'metadata/audit_templateMetaData.php';
$fieldDefs = $dictionary['audit']['fields'];
$indices = $dictionary['audit']['indices'];
// '0' stands for the first index for all the audit tables
$indices[0]['name'] = 'idx_' . strtolower($this->getTableName()) . '_' . $indices[0]['name'];
$indices[1]['name'] = 'idx_' . strtolower($this->getTableName()) . '_' . $indices[1]['name'];
$engine = null;
if (isset($dictionary['audit']['engine'])) {
$engine = $dictionary['audit']['engine'];
} else {
if (isset($dictionary[$this->getObjectName()]['engine'])) {
$engine = $dictionary[$this->getObjectName()]['engine'];
}
}
$sql = $this->db->createTableSQLParams($table_name, $fieldDefs, $indices, $engine);
$msg = "Error creating table: " . $table_name . ":";
$this->db->query($sql, true, $msg);
}