本文整理汇总了PHP中phpbb\db\driver\driver_interface::get_sql_error_triggered方法的典型用法代码示例。如果您正苦于以下问题:PHP driver_interface::get_sql_error_triggered方法的具体用法?PHP driver_interface::get_sql_error_triggered怎么用?PHP driver_interface::get_sql_error_triggered使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpbb\db\driver\driver_interface
的用法示例。
在下文中一共展示了driver_interface::get_sql_error_triggered方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* {@inheritdoc}
*/
public function run()
{
$this->db->sql_return_on_error(true);
$languages = $this->language_helper->get_available_languages();
$installed_languages = array();
foreach ($languages as $lang_info) {
$lang_pack = array('lang_iso' => $lang_info['iso'], 'lang_dir' => $lang_info['iso'], 'lang_english_name' => htmlspecialchars($lang_info['name']), 'lang_local_name' => htmlspecialchars($lang_info['local_name'], ENT_COMPAT, 'UTF-8'), 'lang_author' => htmlspecialchars($lang_info['author'], ENT_COMPAT, 'UTF-8'));
$this->db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $this->db->sql_build_array('INSERT', $lang_pack));
$installed_languages[] = (int) $this->db->sql_nextid();
if ($this->db->get_sql_error_triggered()) {
$error = $this->db->sql_error($this->db->get_sql_error_sql());
$this->iohandler->add_error_message($error['message']);
}
}
$sql = 'SELECT * FROM ' . PROFILE_FIELDS_TABLE;
$result = $this->db->sql_query($sql);
$insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, PROFILE_LANG_TABLE);
while ($row = $this->db->sql_fetchrow($result)) {
foreach ($installed_languages as $lang_id) {
$insert_buffer->insert(array('field_id' => $row['field_id'], 'lang_id' => $lang_id, 'lang_name' => strtoupper(substr($row['field_name'], 6)), 'lang_explain' => '', 'lang_default_value' => ''));
}
}
$this->db->sql_freeresult($result);
$insert_buffer->flush();
}
示例2: load_migration_state
/**
* Loads all migrations and their application state from the database.
*
* @return null
*/
public function load_migration_state()
{
$this->migration_state = array();
// prevent errors in case the table does not exist yet
$this->db->sql_return_on_error(true);
$sql = "SELECT *
FROM " . $this->migrations_table;
$result = $this->db->sql_query($sql);
if (!$this->db->get_sql_error_triggered())
{
while ($migration = $this->db->sql_fetchrow($result))
{
$this->migration_state[$migration['migration_name']] = $migration;
$this->migration_state[$migration['migration_name']]['migration_depends_on'] = unserialize($migration['migration_depends_on']);
}
}
$this->db->sql_freeresult($result);
$this->db->sql_return_on_error(false);
}
示例3: sql_query
/**
* Wrapper for running queries to generate user feedback on updates
*
* @param string $sql SQL query to run on the database
* @return mixed Query result from db->sql_query()
*/
protected function sql_query($sql)
{
$this->queries[] = $sql;
$this->db->sql_return_on_error(true);
if ($sql === 'begin') {
$result = $this->db->sql_transaction('begin');
} else {
if ($sql === 'commit') {
$result = $this->db->sql_transaction('commit');
} else {
$result = $this->db->sql_query($sql);
if ($this->db->get_sql_error_triggered()) {
$this->errors[] = array('sql' => $this->db->get_sql_error_sql(), 'code' => $this->db->get_sql_error_returned());
}
}
}
$this->db->sql_return_on_error(false);
return $result;
}
示例4: add_module_extras
/**
* Add extra modules
*
* @param string $module_class
*/
protected function add_module_extras($module_class)
{
foreach ($this->module_extras[$module_class] as $cat_name => $mods) {
$sql = 'SELECT module_id, left_id, right_id
FROM ' . MODULES_TABLE . "\n\t\t\t\tWHERE module_langname = '" . $this->db->sql_escape($cat_name) . "'\n\t\t\t\t\tAND module_class = '" . $this->db->sql_escape($module_class) . "'";
$result = $this->db->sql_query_limit($sql, 1);
$row2 = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
foreach ($mods as $mod_name) {
$sql = 'SELECT *
FROM ' . MODULES_TABLE . "\n\t\t\t\t\tWHERE module_langname = '" . $this->db->sql_escape($mod_name) . "'\n\t\t\t\t\t\tAND module_class = '" . $this->db->sql_escape($module_class) . "'\n\t\t\t\t\t\tAND module_basename <> ''";
$result = $this->db->sql_query_limit($sql, 1);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
$module_data = array('module_basename' => $row['module_basename'], 'module_enabled' => (int) $row['module_enabled'], 'module_display' => (int) $row['module_display'], 'parent_id' => (int) $row2['module_id'], 'module_class' => $row['module_class'], 'module_langname' => $row['module_langname'], 'module_mode' => $row['module_mode'], 'module_auth' => $row['module_auth']);
$this->module_manager->update_module_data($module_data);
// Check for last sql error happened
if ($this->db->get_sql_error_triggered()) {
$error = $this->db->sql_error($this->db->get_sql_error_sql());
$this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
}
}
}
}
示例5: run
/**
* {@inheritdoc}
*/
public function run()
{
$this->db->sql_return_on_error(true);
$module_classes = array('acp', 'mcp', 'ucp');
foreach ($module_classes as $module_class) {
$categories = array();
foreach ($this->module_categories[$module_class] as $cat_name => $subs) {
// Check if this sub-category has a basename. If it has, use it.
$basename = isset($this->module_categories_basenames[$cat_name]) ? $this->module_categories_basenames[$cat_name] : '';
$module_data = array('module_basename' => $basename, 'module_enabled' => 1, 'module_display' => 1, 'parent_id' => 0, 'module_class' => $module_class, 'module_langname' => $cat_name, 'module_mode' => '', 'module_auth' => '');
$this->module_manager->update_module_data($module_data);
// Check for last sql error happened
if ($this->db->get_sql_error_triggered()) {
$error = $this->db->sql_error($this->db->get_sql_error_sql());
$this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
}
$categories[$cat_name]['id'] = (int) $module_data['module_id'];
$categories[$cat_name]['parent_id'] = 0;
if (is_array($subs)) {
foreach ($subs as $level2_name) {
// Check if this sub-category has a basename. If it has, use it.
$basename = isset($this->module_categories_basenames[$level2_name]) ? $this->module_categories_basenames[$level2_name] : '';
$module_data = array('module_basename' => $basename, 'module_enabled' => 1, 'module_display' => 1, 'parent_id' => (int) $categories[$cat_name]['id'], 'module_class' => $module_class, 'module_langname' => $level2_name, 'module_mode' => '', 'module_auth' => '');
$this->module_manager->update_module_data($module_data);
// Check for last sql error happened
if ($this->db->get_sql_error_triggered()) {
$error = $this->db->sql_error($this->db->get_sql_error_sql());
$this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
}
$categories[$level2_name]['id'] = (int) $module_data['module_id'];
$categories[$level2_name]['parent_id'] = (int) $categories[$cat_name]['id'];
}
}
}
// Get the modules we want to add... returned sorted by name
$module_info = $this->module_manager->get_module_infos($module_class);
foreach ($module_info as $module_basename => $fileinfo) {
foreach ($fileinfo['modes'] as $module_mode => $row) {
foreach ($row['cat'] as $cat_name) {
if (!isset($categories[$cat_name])) {
continue;
}
$module_data = array('module_basename' => $module_basename, 'module_enabled' => 1, 'module_display' => isset($row['display']) ? (int) $row['display'] : 1, 'parent_id' => (int) $categories[$cat_name]['id'], 'module_class' => $module_class, 'module_langname' => $row['title'], 'module_mode' => $module_mode, 'module_auth' => $row['auth']);
$this->module_manager->update_module_data($module_data);
// Check for last sql error happened
if ($this->db->get_sql_error_triggered()) {
$error = $this->db->sql_error($this->db->get_sql_error_sql());
$this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
}
}
}
}
// Move some of the modules around since the code above will put them in the wrong place
if ($module_class === 'acp') {
// Move main module 4 up...
$sql = 'SELECT *
FROM ' . MODULES_TABLE . "\n\t\t\t\t\tWHERE module_basename = 'acp_main'\n\t\t\t\t\t\tAND module_class = 'acp'\n\t\t\t\t\t\tAND module_mode = 'main'";
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
$this->module_manager->move_module_by($row, 'acp', 'move_up', 4);
// Move permissions intro screen module 4 up...
$sql = 'SELECT *
FROM ' . MODULES_TABLE . "\n\t\t\t\t\tWHERE module_basename = 'acp_permissions'\n\t\t\t\t\t\tAND module_class = 'acp'\n\t\t\t\t\t\tAND module_mode = 'intro'";
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
$this->module_manager->move_module_by($row, 'acp', 'move_up', 4);
// Move manage users screen module 5 up...
$sql = 'SELECT *
FROM ' . MODULES_TABLE . "\n\t\t\t\t\tWHERE module_basename = 'acp_users'\n\t\t\t\t\t\tAND module_class = 'acp'\n\t\t\t\t\t\tAND module_mode = 'overview'";
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
$this->module_manager->move_module_by($row, 'acp', 'move_up', 5);
// Move extension management module 1 up...
$sql = 'SELECT *
FROM ' . MODULES_TABLE . "\n\t\t\t\t\tWHERE module_langname = 'ACP_EXTENSION_MANAGEMENT'\n\t\t\t\t\t\tAND module_class = 'acp'\n\t\t\t\t\t\tAND module_mode = ''\n\t\t\t\t\t\tAND module_basename = ''";
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
$this->module_manager->move_module_by($row, 'acp', 'move_up', 1);
}
if ($module_class == 'mcp') {
// Move pm report details module 3 down...
$sql = 'SELECT *
FROM ' . MODULES_TABLE . "\n\t\t\t\t\tWHERE module_basename = 'mcp_pm_reports'\n\t\t\t\t\t\tAND module_class = 'mcp'\n\t\t\t\t\t\tAND module_mode = 'pm_report_details'";
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
$this->module_manager->move_module_by($row, 'mcp', 'move_down', 3);
// Move closed pm reports module 3 down...
$sql = 'SELECT *
FROM ' . MODULES_TABLE . "\n\t\t\t\t\tWHERE module_basename = 'mcp_pm_reports'\n\t\t\t\t\t\tAND module_class = 'mcp'\n\t\t\t\t\t\tAND module_mode = 'pm_reports_closed'";
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
//.........这里部分代码省略.........