[ticket/12446] Unnecessary db connect inphpbb_bootstrap_enabled_exts

PHPBB3-12446
This commit is contained in:
Tristan Darricau 2014-06-26 17:17:35 +02:00
parent 9b27d00d5f
commit ff6e026a40
56 changed files with 766 additions and 145 deletions

View file

@ -139,6 +139,11 @@ services:
- @service_container - @service_container
dbal.conn: dbal.conn:
class: phpbb\db\driver\factory
arguments:
- @service_container
dbal.conn.driver:
class: %dbal.driver.class% class: %dbal.driver.class%
calls: calls:
- [sql_connect, [%dbal.dbhost%, %dbal.dbuser%, %dbal.dbpasswd%, %dbal.dbname%, %dbal.dbport%, false, %dbal.new_link%]] - [sql_connect, [%dbal.dbhost%, %dbal.dbuser%, %dbal.dbpasswd%, %dbal.dbname%, %dbal.dbport%, false, %dbal.new_link%]]

View file

@ -371,7 +371,7 @@ function mass_auth($ug_type, $forum_id, $ug_id, $acl_list, $setting)
switch ($sql_type) switch ($sql_type)
{ {
case 'insert': case 'insert':
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'mysql': case 'mysql':
case 'mysql4': case 'mysql4':

View file

@ -313,7 +313,7 @@ function make_post($new_topic_id, $forum_id, $user_id, $post_username, $text, $m
else else
{ {
// Rollback // Rollback
if($db->sql_layer == "mysql") if($db->get_sql_layer() == "mysql")
{ {
$sql = "DELETE FROM " . POSTS_TABLE . " $sql = "DELETE FROM " . POSTS_TABLE . "
WHERE post_id = $new_post_id"; WHERE post_id = $new_post_id";

View file

@ -48,7 +48,7 @@ $sql = "CREATE TABLE {$table_prefix}attachments
AND a.post_id = p.post_id"; AND a.post_id = p.post_id";
$db->sql_query($sql); $db->sql_query($sql);
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'mysql': case 'mysql':
case 'mysql4': case 'mysql4':

View file

@ -46,7 +46,7 @@ $sql = "CREATE TABLE {$table_prefix}posts
WHERE pt.post_id = p.post_id"; WHERE pt.post_id = p.post_id";
$db->sql_query($sql); $db->sql_query($sql);
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'mysql': case 'mysql':
case 'mysql4': case 'mysql4':
@ -142,7 +142,7 @@ while ($row = $db->sql_fetchrow($result))
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'oracle': case 'oracle':
$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id

View file

@ -73,11 +73,6 @@ if (isset($_GET['avatar']))
$db = $phpbb_container->get('dbal.conn'); $db = $phpbb_container->get('dbal.conn');
$phpbb_log = $phpbb_container->get('log'); $phpbb_log = $phpbb_container->get('log');
// Connect to DB
if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false))
{
exit;
}
unset($dbpasswd); unset($dbpasswd);
request_var('', 0, false, false, $request); request_var('', 0, false, false, $request);

View file

@ -90,7 +90,7 @@ class acp_database
$time = time(); $time = time();
$filename = 'backup_' . $time . '_' . unique_id(); $filename = 'backup_' . $time . '_' . unique_id();
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'mysqli': case 'mysqli':
case 'mysql4': case 'mysql4':
@ -133,7 +133,7 @@ class acp_database
else else
{ {
// We might wanna empty out all that junk :D // We might wanna empty out all that junk :D
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'sqlite': case 'sqlite':
case 'sqlite3': case 'sqlite3':
@ -320,7 +320,7 @@ class acp_database
break; break;
} }
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'mysql': case 'mysql':
case 'mysql4': case 'mysql4':
@ -365,10 +365,10 @@ class acp_database
{ {
trigger_error($user->lang['RESTORE_FAILURE'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($user->lang['RESTORE_FAILURE'] . adm_back_link($this->u_action), E_USER_WARNING);
} }
pg_put_line($db->db_connect_id, $sub . "\n"); pg_put_line($db->get_db_connect_id(), $sub . "\n");
} }
pg_put_line($db->db_connect_id, "\\.\n"); pg_put_line($db->get_db_connect_id(), "\\.\n");
pg_end_copy($db->db_connect_id); pg_end_copy($db->get_db_connect_id());
} }
} }
break; break;
@ -623,7 +623,7 @@ class mysql_extractor extends base_extractor
if ($new_extract === null) if ($new_extract === null)
{ {
if ($db->sql_layer === 'mysqli' || version_compare($db->sql_server_info(true), '3.23.20', '>=')) if ($db->get_sql_layer() === 'mysqli' || version_compare($db->sql_server_info(true), '3.23.20', '>='))
{ {
$new_extract = true; $new_extract = true;
} }
@ -646,7 +646,7 @@ class mysql_extractor extends base_extractor
function write_data($table_name) function write_data($table_name)
{ {
global $db; global $db;
if ($db->sql_layer === 'mysqli') if ($db->get_sql_layer() === 'mysqli')
{ {
$this->write_data_mysqli($table_name); $this->write_data_mysqli($table_name);
} }
@ -661,7 +661,7 @@ class mysql_extractor extends base_extractor
global $db; global $db;
$sql = "SELECT * $sql = "SELECT *
FROM $table_name"; FROM $table_name";
$result = mysqli_query($db->db_connect_id, $sql, MYSQLI_USE_RESULT); $result = mysqli_query($db->get_db_connect_id(), $sql, MYSQLI_USE_RESULT);
if ($result != false) if ($result != false)
{ {
$fields_cnt = mysqli_num_fields($result); $fields_cnt = mysqli_num_fields($result);
@ -740,7 +740,7 @@ class mysql_extractor extends base_extractor
global $db; global $db;
$sql = "SELECT * $sql = "SELECT *
FROM $table_name"; FROM $table_name";
$result = mysql_unbuffered_query($sql, $db->db_connect_id); $result = mysql_unbuffered_query($sql, $db->get_db_connect_id());
if ($result != false) if ($result != false)
{ {
@ -993,11 +993,11 @@ class sqlite_extractor extends base_extractor
{ {
global $db; global $db;
$col_types = sqlite_fetch_column_types($db->db_connect_id, $table_name); $col_types = sqlite_fetch_column_types($db->get_db_connect_id(), $table_name);
$sql = "SELECT * $sql = "SELECT *
FROM $table_name"; FROM $table_name";
$result = sqlite_unbuffered_query($db->db_connect_id, $sql); $result = sqlite_unbuffered_query($db->get_db_connect_id(), $sql);
$rows = sqlite_fetch_all($result, SQLITE_ASSOC); $rows = sqlite_fetch_all($result, SQLITE_ASSOC);
$sql_insert = 'INSERT INTO ' . $table_name . ' (' . implode(', ', array_keys($col_types)) . ') VALUES ('; $sql_insert = 'INSERT INTO ' . $table_name . ' (' . implode(', ', array_keys($col_types)) . ') VALUES (';
foreach ($rows as $row) foreach ($rows as $row)
@ -1553,11 +1553,11 @@ class mssql_extractor extends base_extractor
{ {
global $db; global $db;
if ($db->sql_layer === 'mssql') if ($db->get_sql_layer() === 'mssql')
{ {
$this->write_data_mssql($table_name); $this->write_data_mssql($table_name);
} }
else if($db->sql_layer === 'mssqlnative') else if($db->get_sql_layer() === 'mssqlnative')
{ {
$this->write_data_mssqlnative($table_name); $this->write_data_mssqlnative($table_name);
} }

View file

@ -1827,7 +1827,7 @@ class acp_forums
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'mysql4': case 'mysql4':
case 'mysqli': case 'mysqli':

View file

@ -538,7 +538,7 @@ class acp_icons
// The user has already selected a smilies_pak file // The user has already selected a smilies_pak file
if ($current == 'delete') if ($current == 'delete')
{ {
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'sqlite': case 'sqlite':
case 'sqlite3': case 'sqlite3':

View file

@ -269,7 +269,7 @@ class acp_main
break; break;
case 'db_track': case 'db_track':
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'sqlite': case 'sqlite':
case 'sqlite3': case 'sqlite3':
@ -374,7 +374,7 @@ class acp_main
foreach ($tables as $table) foreach ($tables as $table)
{ {
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'sqlite': case 'sqlite':
case 'sqlite3': case 'sqlite3':

View file

@ -253,7 +253,7 @@ class acp_permission_roles
{ {
$sql = 'SELECT auth_option_id, auth_option $sql = 'SELECT auth_option_id, auth_option
FROM ' . ACL_OPTIONS_TABLE . " FROM ' . ACL_OPTIONS_TABLE . "
WHERE auth_option " . $db->sql_like_expression($permission_type . $db->any_char) . " WHERE auth_option " . $db->sql_like_expression($permission_type . $db->get_any_char()) . "
AND auth_option <> '{$permission_type}' AND auth_option <> '{$permission_type}'
ORDER BY auth_option_id"; ORDER BY auth_option_id";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
@ -315,7 +315,7 @@ class acp_permission_roles
// We need to fill the auth options array with ACL_NO options ;) // We need to fill the auth options array with ACL_NO options ;)
$sql = 'SELECT auth_option_id, auth_option $sql = 'SELECT auth_option_id, auth_option
FROM ' . ACL_OPTIONS_TABLE . " FROM ' . ACL_OPTIONS_TABLE . "
WHERE auth_option " . $db->sql_like_expression($permission_type . $db->any_char) . " WHERE auth_option " . $db->sql_like_expression($permission_type . $db->get_any_char()) . "
AND auth_option <> '{$permission_type}' AND auth_option <> '{$permission_type}'
ORDER BY auth_option_id"; ORDER BY auth_option_id";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
@ -519,7 +519,7 @@ class acp_permission_roles
// Get complete auth array // Get complete auth array
$sql = 'SELECT auth_option, auth_option_id $sql = 'SELECT auth_option, auth_option_id
FROM ' . ACL_OPTIONS_TABLE . " FROM ' . ACL_OPTIONS_TABLE . "
WHERE auth_option " . $db->sql_like_expression($permission_type . $db->any_char); WHERE auth_option " . $db->sql_like_expression($permission_type . $db->get_any_char());
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$auth_settings = array(); $auth_settings = array();

View file

@ -1238,7 +1238,7 @@ class acp_permissions
$sql = 'SELECT auth_option_id $sql = 'SELECT auth_option_id
FROM ' . ACL_OPTIONS_TABLE . ' FROM ' . ACL_OPTIONS_TABLE . '
WHERE auth_option ' . $db->sql_like_expression($permission_type . $db->any_char); WHERE auth_option ' . $db->sql_like_expression($permission_type . $db->get_any_char());
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))

View file

@ -112,7 +112,7 @@ class acp_profile
$db->sql_query('DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " WHERE field_id = $field_id"); $db->sql_query('DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " WHERE field_id = $field_id");
$db->sql_query('DELETE FROM ' . PROFILE_LANG_TABLE . " WHERE field_id = $field_id"); $db->sql_query('DELETE FROM ' . PROFILE_LANG_TABLE . " WHERE field_id = $field_id");
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'sqlite': case 'sqlite':
case 'sqlite3': case 'sqlite3':
@ -1196,7 +1196,7 @@ class acp_profile
{ {
global $db; global $db;
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'mysql': case 'mysql':
case 'mysql4': case 'mysql4':

View file

@ -436,8 +436,8 @@ class acp_prune
$sort_by_types = array('username', 'user_email', 'user_posts', 'user_regdate', 'user_lastvisit'); $sort_by_types = array('username', 'user_email', 'user_posts', 'user_regdate', 'user_lastvisit');
$where_sql = ''; $where_sql = '';
$where_sql .= ($username) ? ' AND username_clean ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($username))) : ''; $where_sql .= ($username) ? ' AND username_clean ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($username))) : '';
$where_sql .= ($email) ? ' AND user_email ' . $db->sql_like_expression(str_replace('*', $db->any_char, $email)) . ' ' : ''; $where_sql .= ($email) ? ' AND user_email ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), $email)) . ' ' : '';
$where_sql .= $joined_sql; $where_sql .= $joined_sql;
$where_sql .= ($count) ? " AND user_posts " . $key_match[$count_select] . ' ' . (int) $count . ' ' : ''; $where_sql .= ($count) ? " AND user_posts " . $key_match[$count_select] . ' ' . (int) $count . ' ' : '';

View file

@ -219,7 +219,7 @@ class acp_reasons
$other_reason_id = (int) $db->sql_fetchfield('reason_id'); $other_reason_id = (int) $db->sql_fetchfield('reason_id');
$db->sql_freeresult($result); $db->sql_freeresult($result);
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
// The ugly one! // The ugly one!
case 'mysqli': case 'mysqli':

View file

@ -2384,7 +2384,7 @@ class acp_users
// Select auth options // Select auth options
$sql = 'SELECT auth_option, is_local, is_global $sql = 'SELECT auth_option, is_local, is_global
FROM ' . ACL_OPTIONS_TABLE . ' FROM ' . ACL_OPTIONS_TABLE . '
WHERE auth_option ' . $db->sql_like_expression($db->any_char . '_') . ' WHERE auth_option ' . $db->sql_like_expression($db->get_any_char() . '_') . '
AND is_global = 1 AND is_global = 1
ORDER BY auth_option'; ORDER BY auth_option';
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
@ -2404,7 +2404,7 @@ class acp_users
{ {
$sql = 'SELECT auth_option, is_local, is_global $sql = 'SELECT auth_option, is_local, is_global
FROM ' . ACL_OPTIONS_TABLE . " FROM ' . ACL_OPTIONS_TABLE . "
WHERE auth_option " . $db->sql_like_expression($db->any_char . '_') . " WHERE auth_option " . $db->sql_like_expression($db->get_any_char() . '_') . "
AND is_local = 1 AND is_local = 1
ORDER BY is_global DESC, auth_option"; ORDER BY is_global DESC, auth_option";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);

View file

@ -1024,7 +1024,7 @@ class auth_admin extends \phpbb\auth\auth
// Get permission type // Get permission type
$sql = 'SELECT auth_option, auth_option_id $sql = 'SELECT auth_option, auth_option_id
FROM ' . ACL_OPTIONS_TABLE . " FROM ' . ACL_OPTIONS_TABLE . "
WHERE auth_option " . $db->sql_like_expression($permission_type . $db->any_char); WHERE auth_option " . $db->sql_like_expression($permission_type . $db->get_any_char());
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$auth_id_ary = array(); $auth_id_ary = array();

View file

@ -3998,7 +3998,7 @@ function obtain_guest_count($item_id = 0, $item = 'forum')
// Get number of online guests // Get number of online guests
if ($db->sql_layer === 'sqlite' || $db->sql_layer === 'sqlite3') if ($db->get_sql_layer() === 'sqlite' || $db->get_sql_layer() === 'sqlite3')
{ {
$sql = 'SELECT COUNT(session_ip) as num_guests $sql = 'SELECT COUNT(session_ip) as num_guests
FROM ( FROM (
@ -5064,7 +5064,7 @@ function phpbb_generate_debug_output(phpbb\db\driver\driver_interface $db, \phpb
if (isset($GLOBALS['starttime'])) if (isset($GLOBALS['starttime']))
{ {
$totaltime = microtime(true) - $GLOBALS['starttime']; $totaltime = microtime(true) - $GLOBALS['starttime'];
$debug_info[] = sprintf('<abbr title="SQL time: %.3fs / PHP time: %.3fs">Time: %.3fs</abbr>', $db->sql_time, ($totaltime - $db->sql_time), $totaltime); $debug_info[] = sprintf('<abbr title="SQL time: %.3fs / PHP time: %.3fs">Time: %.3fs</abbr>', $db->get_sql_time(), ($totaltime - $db->get_sql_time()), $totaltime);
} }
$debug_info[] = sprintf('<abbr title="Cached: %d">Queries: %d</abbr>', $db->sql_num_queries(true), $db->sql_num_queries()); $debug_info[] = sprintf('<abbr title="Cached: %d">Queries: %d</abbr>', $db->sql_num_queries(true), $db->sql_num_queries());

View file

@ -1435,7 +1435,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
{ {
case 'topic_moved': case 'topic_moved':
$db->sql_transaction('begin'); $db->sql_transaction('begin');
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'mysql4': case 'mysql4':
case 'mysqli': case 'mysqli':
@ -2441,7 +2441,7 @@ function phpbb_cache_moderators($db, $cache, $auth)
$cache->destroy('sql', MODERATOR_CACHE_TABLE); $cache->destroy('sql', MODERATOR_CACHE_TABLE);
// Clear table // Clear table
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'sqlite': case 'sqlite':
case 'sqlite3': case 'sqlite3':
@ -2491,7 +2491,7 @@ function phpbb_cache_moderators($db, $cache, $auth)
AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1)
AND ' . $db->sql_in_set('ug.user_id', $ug_id_ary) . " AND ' . $db->sql_in_set('ug.user_id', $ug_id_ary) . "
AND ug.user_pending = 0 AND ug.user_pending = 0
AND o.auth_option " . $db->sql_like_expression('m_' . $db->any_char), AND o.auth_option " . $db->sql_like_expression('m_' . $db->get_any_char()),
); );
$sql = $db->sql_build_query('SELECT', $sql_ary_deny); $sql = $db->sql_build_query('SELECT', $sql_ary_deny);
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
@ -2697,11 +2697,11 @@ function phpbb_update_foes($db, $auth, $group_id = false, $user_id = false)
return; return;
} }
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'mysqli': case 'mysqli':
case 'mysql4': case 'mysql4':
$sql = 'DELETE ' . (($db->sql_layer === 'mysqli' || version_compare($db->sql_server_info(true), '4.1', '>=')) ? 'z.*' : ZEBRA_TABLE) . ' $sql = 'DELETE ' . (($db->get_sql_layer() === 'mysqli' || version_compare($db->sql_server_info(true), '4.1', '>=')) ? 'z.*' : ZEBRA_TABLE) . '
FROM ' . ZEBRA_TABLE . ' z, ' . USER_GROUP_TABLE . ' ug FROM ' . ZEBRA_TABLE . ' z, ' . USER_GROUP_TABLE . ' ug
WHERE z.zebra_id = ug.user_id WHERE z.zebra_id = ug.user_id
AND z.foe = 1 AND z.foe = 1
@ -2854,7 +2854,7 @@ function get_database_size()
$database_size = false; $database_size = false;
// This code is heavily influenced by a similar routine in phpMyAdmin 2.2.0 // This code is heavily influenced by a similar routine in phpMyAdmin 2.2.0
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'mysql': case 'mysql':
case 'mysql4': case 'mysql4':
@ -2870,7 +2870,7 @@ function get_database_size()
if (preg_match('#(3\.23|[45]\.)#', $version)) if (preg_match('#(3\.23|[45]\.)#', $version))
{ {
$db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.#', $version)) ? "`{$db->dbname}`" : $db->dbname; $db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.#', $version)) ? "`{$db->get_db_name()}`" : $db->get_db_name();
$sql = 'SHOW TABLE STATUS $sql = 'SHOW TABLE STATUS
FROM ' . $db_name; FROM ' . $db_name;
@ -2946,7 +2946,7 @@ function get_database_size()
if ($row['proname'] == 'pg_database_size') if ($row['proname'] == 'pg_database_size')
{ {
$database = $db->dbname; $database = $db->get_db_name();
if (strpos($database, '.') !== false) if (strpos($database, '.') !== false)
{ {
list($database, ) = explode('.', $database); list($database, ) = explode('.', $database);

View file

@ -64,9 +64,10 @@ function phpbb_bootstrap_table_prefix($config_file)
* *
* @param string $config_file * @param string $config_file
* @param string $phpbb_root_path * @param string $phpbb_root_path
* @param \phpbb\db\driver\driver_interface $db The generated connection
* @return array enabled extensions * @return array enabled extensions
*/ */
function phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path) function phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path, &$db)
{ {
$db = phpbb_bootstrap_db_connection($config_file); $db = phpbb_bootstrap_db_connection($config_file);
$table_prefix = phpbb_bootstrap_table_prefix($config_file); $table_prefix = phpbb_bootstrap_table_prefix($config_file);
@ -133,7 +134,7 @@ function phpbb_create_install_container($phpbb_root_path, $php_ext)
$container->setParameter('core.php_ext', $php_ext); $container->setParameter('core.php_ext', $php_ext);
$container->setParameter('core.table_prefix', ''); $container->setParameter('core.table_prefix', '');
$container->register('dbal.conn')->setSynthetic(true); $container->register('dbal.conn.driver')->setSynthetic(true);
$container->setAlias('cache.driver', 'cache.driver.install'); $container->setAlias('cache.driver', 'cache.driver.install');
@ -259,9 +260,10 @@ function phpbb_create_dumped_container_unless_debug($config_file, array $extensi
function phpbb_create_default_container($phpbb_root_path, $php_ext) function phpbb_create_default_container($phpbb_root_path, $php_ext)
{ {
$config_file = $phpbb_root_path . 'config.' . $php_ext; $config_file = $phpbb_root_path . 'config.' . $php_ext;
$installed_exts = phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path); $db = null;
$installed_exts = phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path, $db);
return phpbb_create_dumped_container_unless_debug( $container = phpbb_create_dumped_container_unless_debug(
$config_file, $config_file,
array( array(
new \phpbb\di\extension\config($config_file), new \phpbb\di\extension\config($config_file),
@ -275,6 +277,10 @@ function phpbb_create_default_container($phpbb_root_path, $php_ext)
$phpbb_root_path, $phpbb_root_path,
$php_ext $php_ext
); );
$container->get('dbal.conn')->set_driver($db);
return $container;
} }
/** /**

View file

@ -1647,7 +1647,7 @@ function mass_auth($ug_type, $forum_id, $ug_id, $acl_list, $setting = ACL_NO)
switch ($sql_type) switch ($sql_type)
{ {
case 'insert': case 'insert':
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'mysql': case 'mysql':
case 'mysql4': case 'mysql4':
@ -2041,7 +2041,7 @@ function update_topics_posted()
{ {
global $db, $config; global $db, $config;
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'sqlite': case 'sqlite':
case 'sqlite3': case 'sqlite3':

View file

@ -290,7 +290,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
switch ($dbms_details['DRIVER']) switch ($dbms_details['DRIVER'])
{ {
case 'phpbb\db\driver\mysqli': case 'phpbb\db\driver\mysqli':
if (version_compare(mysqli_get_server_info($db->db_connect_id), '4.1.3', '<')) if (version_compare(mysqli_get_server_info($db->get_db_connect_id()), '4.1.3', '<'))
{ {
$error[] = $lang['INST_ERR_DB_NO_MYSQLI']; $error[] = $lang['INST_ERR_DB_NO_MYSQLI'];
} }

View file

@ -1350,7 +1350,7 @@ class parse_message extends bbcode_firstpass
// NOTE: obtain_* function? chaching the table contents? // NOTE: obtain_* function? chaching the table contents?
// For now setting the ttl to 10 minutes // For now setting the ttl to 10 minutes
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'mssql': case 'mssql':
case 'mssql_odbc': case 'mssql_odbc':

View file

@ -92,7 +92,7 @@ function phpbb_insert_forums()
$src_db->sql_query("SET NAMES 'utf8'"); $src_db->sql_query("SET NAMES 'utf8'");
} }
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'mssql': case 'mssql':
case 'mssql_odbc': case 'mssql_odbc':
@ -289,7 +289,7 @@ function phpbb_insert_forums()
} }
$src_db->sql_freeresult($result); $src_db->sql_freeresult($result);
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'postgres': case 'postgres':
$db->sql_query("SELECT SETVAL('" . FORUMS_TABLE . "_seq',(select case when max(forum_id)>0 then max(forum_id)+1 else 1 end from " . FORUMS_TABLE . '));'); $db->sql_query("SELECT SETVAL('" . FORUMS_TABLE . "_seq',(select case when max(forum_id)>0 then max(forum_id)+1 else 1 end from " . FORUMS_TABLE . '));');
@ -1768,7 +1768,7 @@ function phpbb_create_userconv_table()
global $db, $src_db, $convert, $table_prefix, $user, $lang; global $db, $src_db, $convert, $table_prefix, $user, $lang;
$map_dbms = ''; $map_dbms = '';
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'mysql': case 'mysql':
$map_dbms = 'mysql_40'; $map_dbms = 'mysql_40';
@ -1796,7 +1796,7 @@ function phpbb_create_userconv_table()
break; break;
default: default:
$map_dbms = $db->sql_layer; $map_dbms = $db->get_sql_layer();
break; break;
} }

View file

@ -176,7 +176,7 @@ header('Content-type: text/html; charset=UTF-8');
<br /> <br />
<p><?php echo $user->lang['DATABASE_TYPE']; ?> :: <strong><?php echo $db->sql_layer; ?></strong><br /> <p><?php echo $user->lang['DATABASE_TYPE']; ?> :: <strong><?php echo $db->get_sql_layer(); ?></strong><br />
<?php echo $user->lang['PREVIOUS_VERSION']; ?> :: <strong><?php echo $config['version']; ?></strong><br /> <?php echo $user->lang['PREVIOUS_VERSION']; ?> :: <strong><?php echo $config['version']; ?></strong><br />
<?php <?php

View file

@ -688,7 +688,7 @@ class module
)); ));
// Rollback if in transaction // Rollback if in transaction
if ($db->transaction) if ($db->get_transaction())
{ {
$db->sql_transaction('rollback'); $db->sql_transaction('rollback');
} }

View file

@ -248,7 +248,7 @@ class install_convert extends module
)); ));
} }
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'sqlite': case 'sqlite':
case 'sqlite3': case 'sqlite3':
@ -727,7 +727,7 @@ class install_convert extends module
$src_db->sql_query("SET NAMES 'binary'"); $src_db->sql_query("SET NAMES 'binary'");
} }
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'sqlite': case 'sqlite':
case 'sqlite3': case 'sqlite3':
@ -1129,7 +1129,7 @@ class install_convert extends module
if (!empty($schema['autoincrement'])) if (!empty($schema['autoincrement']))
{ {
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'postgres': case 'postgres':
$db->sql_query("SELECT SETVAL('" . $schema['target'] . "_seq',(select case when max(" . $schema['autoincrement'] . ")>0 then max(" . $schema['autoincrement'] . ")+1 else 1 end from " . $schema['target'] . '));'); $db->sql_query("SELECT SETVAL('" . $schema['target'] . "_seq',(select case when max(" . $schema['autoincrement'] . ")>0 then max(" . $schema['autoincrement'] . ")+1 else 1 end from " . $schema['target'] . '));');
@ -1268,7 +1268,7 @@ class install_convert extends module
if (!empty($schema['autoincrement'])) if (!empty($schema['autoincrement']))
{ {
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'mssql': case 'mssql':
case 'mssql_odbc': case 'mssql_odbc':
@ -1301,7 +1301,7 @@ class install_convert extends module
if ($sql_flag === true) if ($sql_flag === true)
{ {
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
// If MySQL, we'll wait to have num_wait_rows rows to submit at once // If MySQL, we'll wait to have num_wait_rows rows to submit at once
case 'mysql': case 'mysql':
@ -1396,7 +1396,7 @@ class install_convert extends module
if (!empty($schema['autoincrement'])) if (!empty($schema['autoincrement']))
{ {
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'mssql': case 'mssql':
case 'mssql_odbc': case 'mssql_odbc':
@ -1635,7 +1635,7 @@ class install_convert extends module
'RESULT' => $user->lang['DONE'], 'RESULT' => $user->lang['DONE'],
)); ));
if ($db->sql_error_triggered) if ($db->get_sql_error_triggered())
{ {
$template->assign_vars(array( $template->assign_vars(array(
'S_ERROR_BOX' => true, 'S_ERROR_BOX' => true,
@ -1808,7 +1808,7 @@ class install_convert extends module
global $convert; global $convert;
// Can we use IGNORE with this DBMS? // Can we use IGNORE with this DBMS?
$sql_ignore = (strpos($db->sql_layer, 'mysql') === 0 && !defined('DEBUG')) ? 'IGNORE ' : ''; $sql_ignore = (strpos($db->get_sql_layer(), 'mysql') === 0 && !defined('DEBUG')) ? 'IGNORE ' : '';
$insert_query = 'INSERT ' . $sql_ignore . 'INTO ' . $schema['target'] . ' ('; $insert_query = 'INSERT ' . $sql_ignore . 'INTO ' . $schema['target'] . ' (';
$aliases = array(); $aliases = array();

View file

@ -1532,10 +1532,10 @@ class install_install extends module
$_module->update_module_data($module_data, true); $_module->update_module_data($module_data, true);
// Check for last sql error happened // Check for last sql error happened
if ($db->sql_error_triggered) if ($db->get_sql_error_triggered())
{ {
$error = $db->sql_error($db->sql_error_sql); $error = $db->sql_error($db->get_sql_error_sql());
$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__); $this->p_master->db_error($error['message'], $db->get_sql_error_sql(), __LINE__, __FILE__);
} }
$categories[$cat_name]['id'] = (int) $module_data['module_id']; $categories[$cat_name]['id'] = (int) $module_data['module_id'];
@ -1566,10 +1566,10 @@ class install_install extends module
$_module->update_module_data($module_data, true); $_module->update_module_data($module_data, true);
// Check for last sql error happened // Check for last sql error happened
if ($db->sql_error_triggered) if ($db->get_sql_error_triggered())
{ {
$error = $db->sql_error($db->sql_error_sql); $error = $db->sql_error($db->get_sql_error_sql());
$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__); $this->p_master->db_error($error['message'], $db->get_sql_error_sql(), __LINE__, __FILE__);
} }
$categories[$level2_name]['id'] = (int) $module_data['module_id']; $categories[$level2_name]['id'] = (int) $module_data['module_id'];
@ -1606,10 +1606,10 @@ class install_install extends module
$_module->update_module_data($module_data, true); $_module->update_module_data($module_data, true);
// Check for last sql error happened // Check for last sql error happened
if ($db->sql_error_triggered) if ($db->get_sql_error_triggered())
{ {
$error = $db->sql_error($db->sql_error_sql); $error = $db->sql_error($db->get_sql_error_sql());
$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__); $this->p_master->db_error($error['message'], $db->get_sql_error_sql(), __LINE__, __FILE__);
} }
} }
} }
@ -1772,10 +1772,10 @@ class install_install extends module
$_module->update_module_data($module_data, true); $_module->update_module_data($module_data, true);
// Check for last sql error happened // Check for last sql error happened
if ($db->sql_error_triggered) if ($db->get_sql_error_triggered())
{ {
$error = $db->sql_error($db->sql_error_sql); $error = $db->sql_error($db->get_sql_error_sql());
$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__); $this->p_master->db_error($error['message'], $db->get_sql_error_sql(), __LINE__, __FILE__);
} }
} }
} }
@ -1824,10 +1824,10 @@ class install_install extends module
$db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $lang_pack)); $db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $lang_pack));
$installed_languages[] = (int) $db->sql_nextid(); $installed_languages[] = (int) $db->sql_nextid();
if ($db->sql_error_triggered) if ($db->get_sql_error_triggered())
{ {
$error = $db->sql_error($db->sql_error_sql); $error = $db->sql_error($db->get_sql_error_sql());
$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__); $this->p_master->db_error($error['message'], $db->get_sql_error_sql(), __LINE__, __FILE__);
} }
} }
} }
@ -1913,7 +1913,7 @@ class install_install extends module
if (!$user_id) if (!$user_id)
{ {
// If we can't insert this user then continue to the next one to avoid inconsistent data // If we can't insert this user then continue to the next one to avoid inconsistent data
$this->p_master->db_error('Unable to insert bot into users table', $db->sql_error_sql, __LINE__, __FILE__, true); $this->p_master->db_error('Unable to insert bot into users table', $db->get_sql_error_sql(), __LINE__, __FILE__, true);
continue; continue;
} }

View file

@ -799,7 +799,7 @@ switch ($mode)
$sql = 'SELECT username, user_id, user_colour $sql = 'SELECT username, user_id, user_colour
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . ' WHERE ' . $db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . '
AND username_clean ' . $db->sql_like_expression(utf8_clean_string($username_chars) . $db->any_char); AND username_clean ' . $db->sql_like_expression(utf8_clean_string($username_chars) . $db->get_any_char());
$result = $db->sql_query_limit($sql, 10); $result = $db->sql_query_limit($sql, 10);
$user_list = array(); $user_list = array();
@ -920,9 +920,9 @@ switch ($mode)
$s_find_active_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; $s_find_active_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
} }
$sql_where .= ($username) ? ' AND u.username_clean ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($username))) : ''; $sql_where .= ($username) ? ' AND u.username_clean ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($username))) : '';
$sql_where .= ($auth->acl_get('a_user') && $email) ? ' AND u.user_email ' . $db->sql_like_expression(str_replace('*', $db->any_char, $email)) . ' ' : ''; $sql_where .= ($auth->acl_get('a_user') && $email) ? ' AND u.user_email ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), $email)) . ' ' : '';
$sql_where .= ($jabber) ? ' AND u.user_jabber ' . $db->sql_like_expression(str_replace('*', $db->any_char, $jabber)) . ' ' : ''; $sql_where .= ($jabber) ? ' AND u.user_jabber ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), $jabber)) . ' ' : '';
$sql_where .= (is_numeric($count) && isset($find_key_match[$count_select])) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : ''; $sql_where .= (is_numeric($count) && isset($find_key_match[$count_select])) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : '';
if (isset($find_key_match[$joined_select]) && sizeof($joined) == 3) if (isset($find_key_match[$joined_select]) && sizeof($joined) == 3)
@ -1016,12 +1016,12 @@ switch ($mode)
{ {
for ($i = 97; $i < 123; $i++) for ($i = 97; $i < 123; $i++)
{ {
$sql_where .= ' AND u.username_clean NOT ' . $db->sql_like_expression(chr($i) . $db->any_char); $sql_where .= ' AND u.username_clean NOT ' . $db->sql_like_expression(chr($i) . $db->get_any_char());
} }
} }
else if ($first_char) else if ($first_char)
{ {
$sql_where .= ' AND u.username_clean ' . $db->sql_like_expression(substr($first_char, 0, 1) . $db->any_char); $sql_where .= ' AND u.username_clean ' . $db->sql_like_expression(substr($first_char, 0, 1) . $db->get_any_char());
} }
// Are we looking at a usergroup? If so, fetch additional info // Are we looking at a usergroup? If so, fetch additional info

View file

@ -1043,7 +1043,7 @@ class auth
{ {
if (strpos($auth_options, '%') !== false) if (strpos($auth_options, '%') !== false)
{ {
$sql_opts = "AND $key " . $db->sql_like_expression(str_replace('%', $db->any_char, $auth_options)); $sql_opts = "AND $key " . $db->sql_like_expression(str_replace('%', $db->get_any_char(), $auth_options));
} }
else else
{ {
@ -1074,7 +1074,7 @@ class auth
{ {
if (strpos($option, '%') !== false) if (strpos($option, '%') !== false)
{ {
$sql[] = $key . ' ' . $db->sql_like_expression(str_replace('%', $db->any_char, $option)); $sql[] = $key . ' ' . $db->sql_like_expression(str_replace('%', $db->get_any_char(), $option));
} }
else else
{ {

View file

@ -305,7 +305,7 @@ class service
{ {
if (($bots = $this->driver->get('_bots')) === false) if (($bots = $this->driver->get('_bots')) === false)
{ {
switch ($this->db->sql_layer) switch ($this->db->get_sql_layer())
{ {
case 'mssql': case 'mssql':
case 'mssql_odbc': case 'mssql_odbc':

View file

@ -45,11 +45,11 @@ class prune_shadow_topics extends \phpbb\cron\task\base implements \phpbb\cron\t
* @param string $phpbb_root_path The root path * @param string $phpbb_root_path The root path
* @param string $php_ext The PHP extension * @param string $php_ext The PHP extension
* @param \phpbb\config\config $config The config * @param \phpbb\config\config $config The config
* @param \phpbb\db\driver\driver $db The db connection * @param \phpbb\db\driver\driver_interface $db The db connection
* @param \phpbb\log\log $log The phpBB log system * @param \phpbb\log\log $log The phpBB log system
* @param \phpbb\user $user The phpBB user object * @param \phpbb\user $user The phpBB user object
*/ */
public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config, \phpbb\db\driver\driver $db, \phpbb\log\log $log, \phpbb\user $user) public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\log\log $log, \phpbb\user $user)
{ {
$this->phpbb_root_path = $phpbb_root_path; $this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext; $this->php_ext = $php_ext;

View file

@ -86,6 +86,102 @@ abstract class driver implements driver_interface
$this->one_char = chr(0) . '_'; $this->one_char = chr(0) . '_';
} }
/**
* {@inheritdoc}
*/
public function get_sql_layer()
{
return $this->sql_layer;
}
/**
* {@inheritdoc}
*/
public function get_db_name()
{
return $this->dbname;
}
/**
* {@inheritdoc}
*/
public function get_any_char()
{
return $this->any_char;
}
/**
* {@inheritdoc}
*/
public function get_one_char()
{
return $this->one_char;
}
/**
* {@inheritdoc}
*/
public function get_db_connect_id()
{
return $this->db_connect_id;
}
/**
* {@inheritdoc}
*/
public function get_sql_error_triggered()
{
return $this->sql_error_triggered;
}
/**
* {@inheritdoc}
*/
public function get_sql_error_sql()
{
return $this->sql_error_sql;
}
/**
* {@inheritdoc}
*/
public function get_transaction()
{
return $this->transaction;
}
/**
* {@inheritdoc}
*/
public function get_sql_time()
{
return $this->sql_time;
}
/**
* {@inheritdoc}
*/
public function get_sql_error_returned()
{
return $this->sql_error_returned;
}
/**
* {@inheritdoc}
*/
public function get_multi_insert()
{
return $this->multi_insert;
}
/**
* {@inheritdoc}
*/
public function set_multi_insert($multi_insert)
{
$this->multi_insert = $multi_insert;
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View file

@ -15,6 +15,90 @@ namespace phpbb\db\driver;
interface driver_interface interface driver_interface
{ {
/**
* Gets the name of the sql layer.
*
* @return string
*/
public function get_sql_layer();
/**
* Gets the name of the database.
*
* @return string
*/
public function get_db_name();
/**
* Wildcards for matching any (%) character within LIKE expressions
*
* @return string
*/
public function get_any_char();
/**
* Wildcards for matching exactly one (_) character within LIKE expressions
*
* @return string
*/
public function get_one_char();
/**
* Gets the time spent into the queries
*
* @return int
*/
public function get_sql_time();
/**
* Gets the connect ID.
*
* @return mixed
*/
public function get_db_connect_id();
/**
* Indicates if an error was triggered.
*
* @return bool
*/
public function get_sql_error_triggered();
/**
* Gets the last faulty query
*
* @return string
*/
public function get_sql_error_sql();
/**
* Indicates if we are in a transaction.
*
* @return bool
*/
public function get_transaction();
/**
* Gets the returned error.
*
* @return array
*/
public function get_sql_error_returned();
/**
* Indicates if multiple insertion can be used
*
* @return bool
*/
public function get_multi_insert();
/**
* Set if multiple insertion can be used
*
* @param bool $multi_insert
*/
public function set_multi_insert($multi_insert);
/** /**
* Gets the exact number of rows in a specified table. * Gets the exact number of rows in a specified table.
* *

View file

@ -0,0 +1,435 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\db\driver;
use \Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Database Abstraction Layer
*/
class factory implements driver_interface
{
/**
* @var driver_interface
*/
protected $driver = null;
/**
* @var ContainerInterface
*/
protected $container;
/**
* Constructor.
*
* @param ContainerInterface $container A ContainerInterface instance
*/
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
/**
* Return the current driver (and retrieved it from the container if necessary)
*
* @return driver_interface
*/
protected function get_driver()
{
if ($this->driver === null)
{
$this->driver = $this->container->get('dbal.conn.driver');
}
return $this->driver;
}
/**
* Set the current driver
*
* @param driver_interface $driver
*/
public function set_driver(driver_interface $driver)
{
$this->driver = $driver;
}
/**
* {@inheritdoc}
*/
public function get_sql_layer()
{
return $this->get_driver()->get_sql_layer();
}
/**
* {@inheritdoc}
*/
public function get_db_name()
{
return $this->get_driver()->get_db_name();
}
/**
* {@inheritdoc}
*/
public function get_any_char()
{
return $this->get_driver()->get_any_char();
}
/**
* {@inheritdoc}
*/
public function get_one_char()
{
return $this->get_driver()->get_one_char();
}
/**
* {@inheritdoc}
*/
public function get_db_connect_id()
{
return $this->get_driver()->get_db_connect_id();
}
/**
* {@inheritdoc}
*/
public function get_sql_error_triggered()
{
return $this->get_driver()->get_sql_error_triggered();
}
/**
* {@inheritdoc}
*/
public function get_sql_error_sql()
{
return $this->get_driver()->get_sql_error_sql();
}
/**
* {@inheritdoc}
*/
public function get_transaction()
{
return $this->get_driver()->get_transaction();
}
/**
* {@inheritdoc}
*/
public function get_sql_time()
{
return $this->get_driver()->get_sql_time();
}
/**
* {@inheritdoc}
*/
public function get_sql_error_returned()
{
return $this->get_driver()->get_sql_error_returned();
}
/**
* {@inheritdoc}
*/
public function get_multi_insert()
{
return $this->get_driver()->get_multi_insert();
}
/**
* {@inheritdoc}
*/
public function set_multi_insert($multi_insert)
{
$this->get_driver()->set_multi_insert($multi_insert);
}
/**
* {@inheritdoc}
*/
public function get_row_count($table_name)
{
return $this->get_driver()->get_row_count($table_name);
}
/**
* {@inheritdoc}
*/
public function get_estimated_row_count($table_name)
{
return $this->get_driver()->get_estimated_row_count($table_name);
}
/**
* {@inheritdoc}
*/
public function sql_lower_text($column_name)
{
return $this->get_driver()->sql_lower_text($column_name);
}
/**
* {@inheritdoc}
*/
public function sql_error($sql = '')
{
return $this->get_driver()->sql_error($sql);
}
/**
* {@inheritdoc}
*/
public function sql_buffer_nested_transactions()
{
return $this->get_driver()->sql_buffer_nested_transactions();
}
/**
* {@inheritdoc}
*/
public function sql_bit_or($column_name, $bit, $compare = '')
{
return $this->get_driver()->sql_bit_or($column_name, $bit, $compare);
}
/**
* {@inheritdoc}
*/
public function sql_server_info($raw = false, $use_cache = true)
{
return $this->get_driver()->sql_server_info($raw, $use_cache);
}
/**
* {@inheritdoc}
*/
public function sql_return_on_error($fail = false)
{
return $this->get_driver()->sql_return_on_error($fail);
}
/**
* {@inheritdoc}
*/
public function sql_build_array($query, $assoc_ary = array())
{
return $this->get_driver()->sql_build_array($query, $assoc_ary);
}
/**
* {@inheritdoc}
*/
public function sql_fetchrowset($query_id = false)
{
return $this->get_driver()->sql_fetchrowset($query_id);
}
/**
* {@inheritdoc}
*/
public function sql_transaction($status = 'begin')
{
return $this->get_driver()->sql_transaction($status);
}
/**
* {@inheritdoc}
*/
public function sql_concatenate($expr1, $expr2)
{
return $this->get_driver()->sql_concatenate($expr1, $expr2);
}
/**
* {@inheritdoc}
*/
public function sql_case($condition, $action_true, $action_false = false)
{
return $this->get_driver()->sql_case($condition, $action_true, $action_false);
}
/**
* {@inheritdoc}
*/
public function sql_build_query($query, $array)
{
return $this->get_driver()->sql_build_query($query, $array);
}
/**
* {@inheritdoc}
*/
public function sql_fetchfield($field, $rownum = false, $query_id = false)
{
return $this->get_driver()->sql_fetchfield($field, $rownum, $query_id);
}
/**
* {@inheritdoc}
*/
public function sql_fetchrow($query_id = false)
{
return $this->get_driver()->sql_fetchrow($query_id);
}
/**
* {@inheritdoc}
*/
public function cast_expr_to_bigint($expression)
{
return $this->get_driver()->cast_expr_to_bigint($expression);
}
/**
* {@inheritdoc}
*/
public function sql_nextid()
{
return $this->get_driver()->sql_nextid();
}
/**
* {@inheritdoc}
*/
public function sql_add_num_queries($cached = false)
{
return $this->get_driver()->sql_add_num_queries($cached);
}
/**
* {@inheritdoc}
*/
public function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
{
return $this->get_driver()->sql_query_limit($query, $total, $offset, $cache_ttl);
}
/**
* {@inheritdoc}
*/
public function sql_query($query = '', $cache_ttl = 0)
{
return $this->get_driver()->sql_query($query, $cache_ttl);
}
/**
* {@inheritdoc}
*/
public function cast_expr_to_string($expression)
{
return $this->get_driver()->cast_expr_to_string($expression);
}
/**
* {@inheritdoc}
*/
public function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
{
throw new \Exception('Disabled method.');
}
/**
* {@inheritdoc}
*/
public function sql_bit_and($column_name, $bit, $compare = '')
{
return $this->get_driver()->sql_bit_and($column_name, $bit, $compare);
}
/**
* {@inheritdoc}
*/
public function sql_freeresult($query_id = false)
{
return $this->get_driver()->sql_freeresult($query_id);
}
/**
* {@inheritdoc}
*/
public function sql_num_queries($cached = false)
{
return $this->get_driver()->sql_num_queries($cached);
}
/**
* {@inheritdoc}
*/
public function sql_multi_insert($table, $sql_ary)
{
return $this->get_driver()->sql_multi_insert($table, $sql_ary);
}
/**
* {@inheritdoc}
*/
public function sql_affectedrows()
{
return $this->get_driver()->sql_affectedrows();
}
/**
* {@inheritdoc}
*/
public function sql_close()
{
return $this->get_driver()->sql_close();
}
/**
* {@inheritdoc}
*/
public function sql_rowseek($rownum, &$query_id)
{
return $this->get_driver()->sql_rowseek($rownum, $query_id);
}
/**
* {@inheritdoc}
*/
public function sql_escape($msg)
{
return $this->get_driver()->sql_escape($msg);
}
/**
* {@inheritdoc}
*/
public function sql_like_expression($expression)
{
return $this->get_driver()->sql_like_expression($expression);
}
/**
* {@inheritdoc}
*/
public function sql_report($mode, $query = '')
{
return $this->get_driver()->sql_report($mode, $query);
}
/**
* {@inheritdoc}
*/
public function sql_in_set($field, $array, $negate = false, $allow_empty_set = false)
{
return $this->get_driver()->sql_in_set($field, $array, $negate, $allow_empty_set);
}
}

View file

@ -37,7 +37,7 @@ class local_url_bbcode extends \phpbb\db\migration\migration
{ {
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . BBCODES_TABLE . ' FROM ' . BBCODES_TABLE . '
WHERE bbcode_match ' . $this->db->sql_like_expression($this->db->any_char . 'LOCAL_URL' . $this->db->any_char); WHERE bbcode_match ' . $this->db->sql_like_expression($this->db->get_any_char() . 'LOCAL_URL' . $this->db->get_any_char());
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result)) while ($row = $this->db->sql_fetchrow($result))

View file

@ -36,7 +36,7 @@ class release_3_0_4 extends \phpbb\db\migration\migration
public function rename_log_delete_topic() public function rename_log_delete_topic()
{ {
if ($this->db->sql_layer == 'oracle') if ($this->db->get_sql_layer() == 'oracle')
{ {
// log_operation is CLOB - but we can change this later // log_operation is CLOB - but we can change this later
$sql = 'UPDATE ' . $this->table_prefix . "log $sql = 'UPDATE ' . $this->table_prefix . "log

View file

@ -76,7 +76,7 @@ class release_3_0_7_rc1 extends \phpbb\db\migration\migration
{ {
// Delete all text-templates from the template_data // Delete all text-templates from the template_data
$sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . ' $sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . '
WHERE template_filename ' . $this->db->sql_like_expression($this->db->any_char . '.txt'); WHERE template_filename ' . $this->db->sql_like_expression($this->db->get_any_char() . '.txt');
$this->sql_query($sql); $this->sql_query($sql);
} }
} }

View file

@ -89,7 +89,7 @@ class release_3_0_9_rc1 extends \phpbb\db\migration\migration
// Update file extension group names to use language strings, again. // Update file extension group names to use language strings, again.
$sql = 'SELECT group_id, group_name $sql = 'SELECT group_id, group_name
FROM ' . EXTENSION_GROUPS_TABLE . ' FROM ' . EXTENSION_GROUPS_TABLE . '
WHERE group_name ' . $this->db->sql_like_expression('EXT_GROUP_' . $this->db->any_char); WHERE group_name ' . $this->db->sql_like_expression('EXT_GROUP_' . $this->db->get_any_char());
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result)) while ($row = $this->db->sql_fetchrow($result))

View file

@ -18,7 +18,7 @@ class mysql_fulltext_drop extends \phpbb\db\migration\migration
public function effectively_installed() public function effectively_installed()
{ {
// This migration is irrelevant for all non-MySQL DBMSes. // This migration is irrelevant for all non-MySQL DBMSes.
return strpos($this->db->sql_layer, 'mysql') === false; return strpos($this->db->get_sql_layer(), 'mysql') === false;
} }
static public function depends_on() static public function depends_on()

View file

@ -18,7 +18,7 @@ class postgres_fulltext_drop extends \phpbb\db\migration\migration
public function effectively_installed() public function effectively_installed()
{ {
// This migration is irrelevant for all non-PostgreSQL DBMSes. // This migration is irrelevant for all non-PostgreSQL DBMSes.
return strpos($this->db->sql_layer, 'postgres') === false; return strpos($this->db->get_sql_layer(), 'postgres') === false;
} }
static public function depends_on() static public function depends_on()

View file

@ -160,11 +160,11 @@ abstract class migration
else else
{ {
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql);
if ($this->db->sql_error_triggered) if ($this->db->get_sql_error_triggered())
{ {
$this->errors[] = array( $this->errors[] = array(
'sql' => $this->db->sql_error_sql, 'sql' => $this->db->get_sql_error_sql(),
'code' => $this->db->sql_error_returned, 'code' => $this->db->get_sql_error_returned(),
); );
} }
} }

View file

@ -110,7 +110,7 @@ class migrator
FROM " . $this->migrations_table; FROM " . $this->migrations_table;
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql);
if (!$this->db->sql_error_triggered) if (!$this->db->get_sql_error_triggered())
{ {
while ($migration = $this->db->sql_fetchrow($result)) while ($migration = $this->db->sql_fetchrow($result))
{ {

View file

@ -92,7 +92,7 @@ class sql_insert_buffer
// Flush buffer if it is full or when DB does not support multi inserts. // Flush buffer if it is full or when DB does not support multi inserts.
// In the later case, the buffer will always only contain one row. // In the later case, the buffer will always only contain one row.
if (!$this->db->multi_insert || sizeof($this->buffer) >= $this->max_buffered_rows) if (!$this->db->get_multi_insert() || sizeof($this->buffer) >= $this->max_buffered_rows)
{ {
return $this->flush(); return $this->flush();
} }

View file

@ -323,7 +323,7 @@ class tools
$this->dbms_type_map = self::get_dbms_type_map(); $this->dbms_type_map = self::get_dbms_type_map();
// Determine mapping database type // Determine mapping database type
switch ($this->db->sql_layer) switch ($this->db->get_sql_layer())
{ {
case 'mysql': case 'mysql':
$this->sql_layer = 'mysql_40'; $this->sql_layer = 'mysql_40';
@ -354,7 +354,7 @@ class tools
break; break;
default: default:
$this->sql_layer = $this->db->sql_layer; $this->sql_layer = $this->db->get_sql_layer();
break; break;
} }
} }
@ -377,7 +377,7 @@ class tools
*/ */
function sql_list_tables() function sql_list_tables()
{ {
switch ($this->db->sql_layer) switch ($this->db->get_sql_layer())
{ {
case 'mysql': case 'mysql':
case 'mysql4': case 'mysql4':
@ -711,7 +711,7 @@ class tools
$sqlite = false; $sqlite = false;
// For SQLite we need to perform the schema changes in a much more different way // For SQLite we need to perform the schema changes in a much more different way
if (($this->db->sql_layer == 'sqlite' || $this->db->sql_layer == 'sqlite3') && $this->return_statements) if (($this->db->get_sql_layer() == 'sqlite' || $this->db->get_sql_layer() == 'sqlite3') && $this->return_statements)
{ {
$sqlite_data = array(); $sqlite_data = array();
$sqlite = true; $sqlite = true;

View file

@ -737,7 +737,7 @@ class log implements \phpbb\log\log_interface
for ($i = 0, $num_keywords = sizeof($keywords); $i < $num_keywords; $i++) for ($i = 0, $num_keywords = sizeof($keywords); $i < $num_keywords; $i++)
{ {
$keywords_pattern[] = preg_quote($keywords[$i], '#'); $keywords_pattern[] = preg_quote($keywords[$i], '#');
$keywords[$i] = $this->db->sql_like_expression($this->db->any_char . $keywords[$i] . $this->db->any_char); $keywords[$i] = $this->db->sql_like_expression($this->db->get_any_char() . $keywords[$i] . $this->db->get_any_char());
} }
$keywords_pattern = '#' . implode('|', $keywords_pattern) . '#ui'; $keywords_pattern = '#' . implode('|', $keywords_pattern) . '#ui';

View file

@ -282,7 +282,7 @@ class base
$sql_where = ''; $sql_where = '';
foreach ($words as $word) foreach ($words as $word)
{ {
$sql_where .= " OR search_keywords " . $db->sql_like_expression($db->any_char . $word . $db->any_char); $sql_where .= " OR search_keywords " . $db->sql_like_expression($db->get_any_char() . $word . $db->get_any_char());
} }
$sql = 'SELECT search_key $sql = 'SELECT search_key
@ -303,7 +303,7 @@ class base
$sql_where = ''; $sql_where = '';
foreach ($authors as $author) foreach ($authors as $author)
{ {
$sql_where .= (($sql_where) ? ' OR ' : '') . 'search_authors ' . $db->sql_like_expression($db->any_char . ' ' . (int) $author . ' ' . $db->any_char); $sql_where .= (($sql_where) ? ' OR ' : '') . 'search_authors ' . $db->sql_like_expression($db->get_any_char() . ' ' . (int) $author . ' ' . $db->get_any_char());
} }
$sql = 'SELECT search_key $sql = 'SELECT search_key

View file

@ -140,7 +140,7 @@ class fulltext_mysql extends \phpbb\search\base
*/ */
public function init() public function init()
{ {
if ($this->db->sql_layer != 'mysql4' && $this->db->sql_layer != 'mysqli') if ($this->db->get_sql_layer() != 'mysql4' && $this->db->get_sql_layer() != 'mysqli')
{ {
return $this->user->lang['FULLTEXT_MYSQL_INCOMPATIBLE_DATABASE']; return $this->user->lang['FULLTEXT_MYSQL_INCOMPATIBLE_DATABASE'];
} }
@ -764,7 +764,7 @@ class fulltext_mysql extends \phpbb\search\base
if (!isset($this->stats['post_subject'])) if (!isset($this->stats['post_subject']))
{ {
if ($this->db->sql_layer == 'mysqli' || version_compare($this->db->sql_server_info(true), '4.1.3', '>=')) if ($this->db->get_sql_layer() == 'mysqli' || version_compare($this->db->sql_server_info(true), '4.1.3', '>='))
{ {
$alter[] = 'MODIFY post_subject varchar(255) COLLATE utf8_unicode_ci DEFAULT \'\' NOT NULL'; $alter[] = 'MODIFY post_subject varchar(255) COLLATE utf8_unicode_ci DEFAULT \'\' NOT NULL';
} }
@ -777,7 +777,7 @@ class fulltext_mysql extends \phpbb\search\base
if (!isset($this->stats['post_content'])) if (!isset($this->stats['post_content']))
{ {
if ($this->db->sql_layer == 'mysqli' || version_compare($this->db->sql_server_info(true), '4.1.3', '>=')) if ($this->db->get_sql_layer() == 'mysqli' || version_compare($this->db->sql_server_info(true), '4.1.3', '>='))
{ {
$alter[] = 'MODIFY post_text mediumtext COLLATE utf8_unicode_ci NOT NULL'; $alter[] = 'MODIFY post_text mediumtext COLLATE utf8_unicode_ci NOT NULL';
} }
@ -872,7 +872,7 @@ class fulltext_mysql extends \phpbb\search\base
*/ */
protected function get_stats() protected function get_stats()
{ {
if (strpos($this->db->sql_layer, 'mysql') === false) if (strpos($this->db->get_sql_layer(), 'mysql') === false)
{ {
$this->stats = array(); $this->stats = array();
return; return;

View file

@ -758,7 +758,7 @@ class fulltext_native extends \phpbb\search\base
); );
} }
switch ($this->db->sql_layer) switch ($this->db->get_sql_layer())
{ {
case 'mysql4': case 'mysql4':
case 'mysqli': case 'mysqli':
@ -978,7 +978,7 @@ class fulltext_native extends \phpbb\search\base
// If the cache was completely empty count the results // If the cache was completely empty count the results
if (!$total_results) if (!$total_results)
{ {
switch ($this->db->sql_layer) switch ($this->db->get_sql_layer())
{ {
case 'mysql4': case 'mysql4':
case 'mysqli': case 'mysqli':
@ -1000,7 +1000,7 @@ class fulltext_native extends \phpbb\search\base
} }
else else
{ {
if ($this->db->sql_layer == 'sqlite' || $this->db->sql_layer == 'sqlite3') if ($this->db->get_sql_layer() == 'sqlite' || $this->db->get_sql_layer() == 'sqlite3')
{ {
$sql = 'SELECT COUNT(topic_id) as total_results $sql = 'SELECT COUNT(topic_id) as total_results
FROM (SELECT DISTINCT t.topic_id'; FROM (SELECT DISTINCT t.topic_id';
@ -1017,7 +1017,7 @@ class fulltext_native extends \phpbb\search\base
$post_visibility $post_visibility
$sql_fora $sql_fora
AND t.topic_id = p.topic_id AND t.topic_id = p.topic_id
$sql_time" . (($this->db->sql_layer == 'sqlite' || $this->db->sql_layer == 'sqlite3') ? ')' : ''); $sql_time" . (($this->db->get_sql_layer() == 'sqlite' || $this->db->get_sql_layer() == 'sqlite3') ? ')' : '');
} }
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql);
@ -1481,7 +1481,7 @@ class fulltext_native extends \phpbb\search\base
*/ */
public function delete_index($acp_module, $u_action) public function delete_index($acp_module, $u_action)
{ {
switch ($this->db->sql_layer) switch ($this->db->get_sql_layer())
{ {
case 'sqlite': case 'sqlite':
case 'sqlite3': case 'sqlite3':

View file

@ -107,7 +107,7 @@ class fulltext_postgres extends \phpbb\search\base
$this->word_length = array('min' => $this->config['fulltext_postgres_min_word_len'], 'max' => $this->config['fulltext_postgres_max_word_len']); $this->word_length = array('min' => $this->config['fulltext_postgres_min_word_len'], 'max' => $this->config['fulltext_postgres_max_word_len']);
if ($this->db->sql_layer == 'postgres') if ($this->db->get_sql_layer() == 'postgres')
{ {
$pgsql_version = explode(',', substr($this->db->sql_server_info(), 10)); $pgsql_version = explode(',', substr($this->db->sql_server_info(), 10));
$this->version = trim($pgsql_version[0]); $this->version = trim($pgsql_version[0]);
@ -185,7 +185,7 @@ class fulltext_postgres extends \phpbb\search\base
*/ */
public function init() public function init()
{ {
if ($this->db->sql_layer != 'postgres') if ($this->db->get_sql_layer() != 'postgres')
{ {
return $this->user->lang['FULLTEXT_POSTGRES_INCOMPATIBLE_DATABASE']; return $this->user->lang['FULLTEXT_POSTGRES_INCOMPATIBLE_DATABASE'];
} }
@ -869,7 +869,7 @@ class fulltext_postgres extends \phpbb\search\base
*/ */
protected function get_stats() protected function get_stats()
{ {
if ($this->db->sql_layer != 'postgres') if ($this->db->get_sql_layer() != 'postgres')
{ {
$this->stats = array(); $this->stats = array();
return; return;
@ -919,7 +919,7 @@ class fulltext_postgres extends \phpbb\search\base
<dt><label>' . $this->user->lang['FULLTEXT_POSTGRES_TS_NAME'] . '</label><br /><span>' . $this->user->lang['FULLTEXT_POSTGRES_TS_NAME_EXPLAIN'] . '</span></dt> <dt><label>' . $this->user->lang['FULLTEXT_POSTGRES_TS_NAME'] . '</label><br /><span>' . $this->user->lang['FULLTEXT_POSTGRES_TS_NAME_EXPLAIN'] . '</span></dt>
<dd><select name="config[fulltext_postgres_ts_name]">'; <dd><select name="config[fulltext_postgres_ts_name]">';
if ($this->db->sql_layer == 'postgres' && $this->tsearch_usable) if ($this->db->get_sql_layer() == 'postgres' && $this->tsearch_usable)
{ {
$sql = 'SELECT cfgname AS ts_name $sql = 'SELECT cfgname AS ts_name
FROM pg_ts_config'; FROM pg_ts_config';

View file

@ -199,7 +199,7 @@ class fulltext_sphinx
*/ */
public function init() public function init()
{ {
if ($this->db->sql_layer != 'mysql' && $this->db->sql_layer != 'mysql4' && $this->db->sql_layer != 'mysqli' && $this->db->sql_layer != 'postgres') if ($this->db->get_sql_layer() != 'mysql' && $this->db->get_sql_layer() != 'mysql4' && $this->db->get_sql_layer() != 'mysqli' && $this->db->get_sql_layer() != 'postgres')
{ {
return $this->user->lang['FULLTEXT_SPHINX_WRONG_DATABASE']; return $this->user->lang['FULLTEXT_SPHINX_WRONG_DATABASE'];
} }
@ -218,11 +218,11 @@ class fulltext_sphinx
protected function config_generate() protected function config_generate()
{ {
// Check if Database is supported by Sphinx // Check if Database is supported by Sphinx
if ($this->db->sql_layer =='mysql' || $this->db->sql_layer == 'mysql4' || $this->db->sql_layer == 'mysqli') if ($this->db->get_sql_layer() =='mysql' || $this->db->get_sql_layer() == 'mysql4' || $this->db->get_sql_layer() == 'mysqli')
{ {
$this->dbtype = 'mysql'; $this->dbtype = 'mysql';
} }
else if ($this->db->sql_layer == 'postgres') else if ($this->db->get_sql_layer() == 'postgres')
{ {
$this->dbtype = 'pgsql'; $this->dbtype = 'pgsql';
} }

View file

@ -145,7 +145,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
trigger_error($user->lang('TOO_FEW_AUTHOR_CHARS', (int) $config['min_search_author_chars'])); trigger_error($user->lang('TOO_FEW_AUTHOR_CHARS', (int) $config['min_search_author_chars']));
} }
$sql_where = (strpos($author, '*') !== false) ? ' username_clean ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($author))) : " username_clean = '" . $db->sql_escape(utf8_clean_string($author)) . "'"; $sql_where = (strpos($author, '*') !== false) ? ' username_clean ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($author))) : " username_clean = '" . $db->sql_escape(utf8_clean_string($author)) . "'";
$sql = 'SELECT user_id $sql = 'SELECT user_id
FROM ' . USERS_TABLE . " FROM ' . USERS_TABLE . "
@ -159,7 +159,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
$sql_where = (strpos($author, '*') !== false) ? ' post_username ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($author))) : " post_username = '" . $db->sql_escape(utf8_clean_string($author)) . "'"; $sql_where = (strpos($author, '*') !== false) ? ' post_username ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($author))) : " post_username = '" . $db->sql_escape(utf8_clean_string($author)) . "'";
$sql = 'SELECT 1 as guest_post $sql = 'SELECT 1 as guest_post
FROM ' . POSTS_TABLE . " FROM ' . POSTS_TABLE . "
@ -172,7 +172,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
if ($found_guest_post) if ($found_guest_post)
{ {
$author_id_ary[] = ANONYMOUS; $author_id_ary[] = ANONYMOUS;
$sql_author_match = (strpos($author, '*') !== false) ? ' ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($author))) : " = '" . $db->sql_escape(utf8_clean_string($author)) . "'"; $sql_author_match = (strpos($author, '*') !== false) ? ' ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($author))) : " = '" . $db->sql_escape(utf8_clean_string($author)) . "'";
} }
if (!sizeof($author_id_ary)) if (!sizeof($author_id_ary))
@ -1296,7 +1296,7 @@ $template->assign_vars(array(
if ($auth->acl_get('a_search')) if ($auth->acl_get('a_search'))
{ {
// Handle large objects differently for Oracle and MSSQL // Handle large objects differently for Oracle and MSSQL
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'oracle': case 'oracle':
$sql = 'SELECT search_time, search_keywords $sql = 'SELECT search_time, search_keywords

View file

@ -102,7 +102,7 @@ $guest_counter = 0;
// Get number of online guests (if we do not display them) // Get number of online guests (if we do not display them)
if (!$show_guests) if (!$show_guests)
{ {
switch ($db->sql_layer) switch ($db->get_sql_layer())
{ {
case 'sqlite': case 'sqlite':
case 'sqlite3': case 'sqlite3':

View file

@ -22,7 +22,7 @@ class phpbb_dbal_order_lower_test extends phpbb_database_test_case
{ {
$db = $this->new_dbal(); $db = $this->new_dbal();
if (strpos($db->sql_layer, 'mysql') === 0 && version_compare($db->sql_server_info(true, false), '5.6', '>=')) if (strpos($db->get_sql_layer(), 'mysql') === 0 && version_compare($db->sql_server_info(true, false), '5.6', '>='))
{ {
$this->markTestSkipped('MySQL 5.6 fails to order things correctly. See also: http://tracker.phpbb.com/browse/PHPBB3-11571 http://bugs.mysql.com/bug.php?id=69005'); $this->markTestSkipped('MySQL 5.6 fails to order things correctly. See also: http://tracker.phpbb.com/browse/PHPBB3-11571 http://bugs.mysql.com/bug.php?id=69005');
} }

View file

@ -219,8 +219,8 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
{ {
$db = $this->new_dbal(); $db = $this->new_dbal();
$like_expression = str_replace('*', $db->any_char, $like_expression); $like_expression = str_replace('*', $db->get_any_char(), $like_expression);
$like_expression = str_replace('#', $db->one_char, $like_expression); $like_expression = str_replace('#', $db->get_one_char(), $like_expression);
$where = ($like_expression) ? 'username_clean ' . $db->sql_like_expression($like_expression) : ''; $where = ($like_expression) ? 'username_clean ' . $db->sql_like_expression($like_expression) : '';
$result = $db->sql_query('SELECT username_clean $result = $db->sql_query('SELECT username_clean

View file

@ -32,7 +32,7 @@ class phpbb_dbal_sql_insert_buffer_test extends phpbb_database_test_case
public function test_multi_insert_disabled_insert_and_flush() public function test_multi_insert_disabled_insert_and_flush()
{ {
$this->db->multi_insert = false; $this->db->set_multi_insert(false);
$this->assertTrue($this->buffer->insert($this->get_row(1))); $this->assertTrue($this->buffer->insert($this->get_row(1)));
$this->assert_config_count(3); $this->assert_config_count(3);
$this->assertFalse($this->buffer->flush()); $this->assertFalse($this->buffer->flush());
@ -50,7 +50,7 @@ class phpbb_dbal_sql_insert_buffer_test extends phpbb_database_test_case
public function test_multi_insert_disabled_insert_with_flush() public function test_multi_insert_disabled_insert_with_flush()
{ {
$this->db->multi_insert = false; $this->db->set_multi_insert(false);
$this->assertTrue($this->buffer->insert($this->get_row(1))); $this->assertTrue($this->buffer->insert($this->get_row(1)));
$this->assert_config_count(3); $this->assert_config_count(3);
$this->assertTrue($this->buffer->insert($this->get_row(2))); $this->assertTrue($this->buffer->insert($this->get_row(2)));
@ -68,7 +68,7 @@ class phpbb_dbal_sql_insert_buffer_test extends phpbb_database_test_case
public function test_multi_insert_disabled_insert_all_and_flush() public function test_multi_insert_disabled_insert_all_and_flush()
{ {
$this->db->multi_insert = false; $this->db->set_multi_insert(false);
$this->assertTrue($this->buffer->insert_all($this->get_rows(3))); $this->assertTrue($this->buffer->insert_all($this->get_rows(3)));
$this->assert_config_count(5); $this->assert_config_count(5);
} }
@ -93,7 +93,7 @@ class phpbb_dbal_sql_insert_buffer_test extends phpbb_database_test_case
protected function check_multi_insert_support() protected function check_multi_insert_support()
{ {
if (!$this->db->multi_insert) if (!$this->db->get_multi_insert())
{ {
$this->markTestSkipped('Database does not support multi_insert'); $this->markTestSkipped('Database does not support multi_insert');
} }