mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-13 12:35:06 +01:00
- clean up mssql and mssql_odbc, mssql now uses a different method of dealing with IDENTITY
- clean up firebird, I will consider changing it to use fetch array instead of fetch object. it's identity code already uses this method as of right... now :D - fix a tiny bug in MySQL's driver (remember to pass the connect id to all DBAL functions) - add new_link as a new param for sql_connect. This allows you to make connections that are not dependant on each other. This is done for our friends mysql, mssql, postgresql and oracle. Now for everybody else.. (I said this was clever ;) MySQLi and SQLite should always spawn a new connection when you call it while mssql_odbc and firebird both will create new links if you give them different params (different creds) than the previous connection(s). Thus we can always promise new links :D - fixed a bug in the converter - cleaned up the dbal a little git-svn-id: file:///svn/phpbb/trunk@7009 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
0350eb9f3c
commit
1d6fd8e135
@ -191,7 +191,7 @@ $cache = new cache();
|
||||
$db = new $sql_db();
|
||||
|
||||
// Connect to DB
|
||||
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false);
|
||||
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false);
|
||||
|
||||
// We do not need this any longer, unset for safety purposes
|
||||
unset($dbpasswd);
|
||||
|
@ -103,12 +103,9 @@ class dbal
|
||||
$this->sql_transaction('commit');
|
||||
}
|
||||
|
||||
if (sizeof($this->open_queries))
|
||||
foreach ($this->open_queries as $query_id)
|
||||
{
|
||||
foreach ($this->open_queries as $i_query_id => $query_id)
|
||||
{
|
||||
$this->sql_freeresult($query_id);
|
||||
}
|
||||
$this->sql_freeresult($query_id);
|
||||
}
|
||||
|
||||
return $this->_sql_close();
|
||||
|
@ -31,7 +31,7 @@ class dbal_firebird extends dbal
|
||||
/**
|
||||
* Connect to server
|
||||
*/
|
||||
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
|
||||
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
|
||||
{
|
||||
$this->persistency = $persistency;
|
||||
$this->user = $sqluser;
|
||||
@ -273,19 +273,19 @@ class dbal_firebird extends dbal
|
||||
|
||||
if ($query_id !== false && $this->last_query_text != '')
|
||||
{
|
||||
if ($this->query_result && preg_match('#^INSERT[\t\n ]+INTO[\t\n ]+([a-z0-9\_\-]+)#is', $this->last_query_text, $tablename))
|
||||
if ($this->query_result && preg_match('#^INSERT[\t\n ]+INTO[\t\n ]+([a-z0-9\_\-]+)#i', $this->last_query_text, $tablename))
|
||||
{
|
||||
$sql = "SELECT GEN_ID(" . $tablename[1] . "_gen, 0) AS new_id FROM RDB\$DATABASE";
|
||||
$sql = 'SELECT GEN_ID(' . $tablename[1] . '_gen, 0) AS new_id FROM RDB$DATABASE';
|
||||
|
||||
if (!($temp_q_id = @ibase_query($this->db_connect_id, $sql)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$temp_result = @ibase_fetch_object($temp_q_id);
|
||||
$temp_result = @ibase_fetch_assoc($temp_q_id);
|
||||
@ibase_free_result($temp_q_id);
|
||||
|
||||
return ($temp_result) ? $temp_result->NEW_ID : false;
|
||||
return ($temp_result) ? $temp_result['NEW_ID'] : false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ class dbal_mssql extends dbal
|
||||
/**
|
||||
* Connect to server
|
||||
*/
|
||||
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
|
||||
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
|
||||
{
|
||||
$this->persistency = $persistency;
|
||||
$this->user = $sqluser;
|
||||
@ -37,7 +37,7 @@ class dbal_mssql extends dbal
|
||||
|
||||
@ini_set('mssql.charset', 'UTF-8');
|
||||
|
||||
$this->db_connect_id = ($this->persistency) ? @mssql_pconnect($this->server, $this->user, $sqlpassword) : @mssql_connect($this->server, $this->user, $sqlpassword);
|
||||
$this->db_connect_id = ($this->persistency) ? @mssql_pconnect($this->server, $this->user, $sqlpassword, $new_link) : @mssql_connect($this->server, $this->user, $sqlpassword, $new_link);
|
||||
|
||||
if ($this->db_connect_id && $this->dbname != '')
|
||||
{
|
||||
@ -86,11 +86,11 @@ class dbal_mssql extends dbal
|
||||
break;
|
||||
|
||||
case 'commit':
|
||||
return @mssql_query('commit', $this->db_connect_id);
|
||||
return @mssql_query('COMMIT TRANSACTION', $this->db_connect_id);
|
||||
break;
|
||||
|
||||
case 'rollback':
|
||||
return @mssql_query('ROLLBACK', $this->db_connect_id);
|
||||
return @mssql_query('ROLLBACK TRANSACTION', $this->db_connect_id);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -258,7 +258,7 @@ class dbal_mssql extends dbal
|
||||
*/
|
||||
function sql_nextid()
|
||||
{
|
||||
$result_id = @mssql_query('SELECT @@IDENTITY', $this->db_connect_id);
|
||||
$result_id = @mssql_query('SELECT SCOPE_IDENTITY()', $this->db_connect_id);
|
||||
if ($result_id)
|
||||
{
|
||||
if ($row = @mssql_fetch_assoc($result_id))
|
||||
@ -385,7 +385,7 @@ class dbal_mssql extends dbal
|
||||
if (preg_match('/^SELECT/', $explain_query))
|
||||
{
|
||||
$html_table = false;
|
||||
@mssql_query("SET SHOWPLAN_TEXT ON;", $this->db_connect_id);
|
||||
@mssql_query('SET SHOWPLAN_TEXT ON;', $this->db_connect_id);
|
||||
if ($result = @mssql_query($explain_query, $this->db_connect_id))
|
||||
{
|
||||
@mssql_next_result($result);
|
||||
@ -394,7 +394,7 @@ class dbal_mssql extends dbal
|
||||
$html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
|
||||
}
|
||||
}
|
||||
@mssql_query("SET SHOWPLAN_TEXT OFF;", $this->db_connect_id);
|
||||
@mssql_query('SET SHOWPLAN_TEXT OFF;', $this->db_connect_id);
|
||||
@mssql_free_result($result);
|
||||
|
||||
if ($html_table)
|
||||
|
@ -31,7 +31,7 @@ class dbal_mssql_odbc extends dbal
|
||||
/**
|
||||
* Connect to server
|
||||
*/
|
||||
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
|
||||
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
|
||||
{
|
||||
$this->persistency = $persistency;
|
||||
$this->user = $sqluser;
|
||||
@ -267,7 +267,7 @@ class dbal_mssql_odbc extends dbal
|
||||
{
|
||||
if (@odbc_fetch_array($result_id))
|
||||
{
|
||||
$id = @odbc_result($result_id, 1);
|
||||
$id = @odbc_result($result_id, 1);
|
||||
@odbc_free_result($result_id);
|
||||
return $id;
|
||||
}
|
||||
@ -363,7 +363,7 @@ class dbal_mssql_odbc extends dbal
|
||||
if (preg_match('/^SELECT/', $explain_query))
|
||||
{
|
||||
$html_table = false;
|
||||
@odbc_exec($this->db_connect_id, "SET SHOWPLAN_TEXT ON;");
|
||||
@odbc_exec($this->db_connect_id, 'SET SHOWPLAN_TEXT ON;');
|
||||
if ($result = @odbc_exec($this->db_connect_id, $explain_query))
|
||||
{
|
||||
@odbc_next_result($result);
|
||||
@ -372,7 +372,7 @@ class dbal_mssql_odbc extends dbal
|
||||
$html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
|
||||
}
|
||||
}
|
||||
@odbc_exec($this->db_connect_id, "SET SHOWPLAN_TEXT OFF;");
|
||||
@odbc_exec($this->db_connect_id, 'SET SHOWPLAN_TEXT OFF;');
|
||||
@odbc_free_result($result);
|
||||
|
||||
if ($html_table)
|
||||
|
@ -35,7 +35,7 @@ class dbal_mysql extends dbal
|
||||
* Connect to server
|
||||
* @access public
|
||||
*/
|
||||
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
|
||||
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
|
||||
{
|
||||
$this->persistency = $persistency;
|
||||
$this->user = $sqluser;
|
||||
@ -44,11 +44,11 @@ class dbal_mysql extends dbal
|
||||
|
||||
$this->sql_layer = 'mysql4';
|
||||
|
||||
$this->db_connect_id = ($this->persistency) ? @mysql_pconnect($this->server, $this->user, $sqlpassword) : @mysql_connect($this->server, $this->user, $sqlpassword);
|
||||
$this->db_connect_id = ($this->persistency) ? @mysql_pconnect($this->server, $this->user, $sqlpassword, $new_link) : @mysql_connect($this->server, $this->user, $sqlpassword, $new_link);
|
||||
|
||||
if ($this->db_connect_id && $this->dbname != '')
|
||||
{
|
||||
if (@mysql_select_db($this->dbname))
|
||||
if (@mysql_select_db($this->dbname, $this->db_connect_id))
|
||||
{
|
||||
// Determine what version we are using and if it natively supports UNICODE
|
||||
$this->mysql_version = mysql_get_server_info($this->db_connect_id);
|
||||
|
@ -29,7 +29,7 @@ class dbal_mysqli extends dbal
|
||||
/**
|
||||
* Connect to server
|
||||
*/
|
||||
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
|
||||
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false , $new_link = false)
|
||||
{
|
||||
$this->persistency = $persistency;
|
||||
$this->user = $sqluser;
|
||||
|
@ -29,14 +29,14 @@ class dbal_oracle extends dbal
|
||||
/**
|
||||
* Connect to server
|
||||
*/
|
||||
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
|
||||
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
|
||||
{
|
||||
$this->persistency = $persistency;
|
||||
$this->user = $sqluser;
|
||||
$this->server = $sqlserver . (($port) ? ':' . $port : '');
|
||||
$this->dbname = $database;
|
||||
|
||||
$this->db_connect_id = ($this->persistency) ? @ociplogon($this->user, $sqlpassword, $this->server, 'UTF8') : @ocinlogon($this->user, $sqlpassword, $this->server, 'UTF8');
|
||||
$this->db_connect_id = ($new_link) ? @ocinlogon($this->user, $sqlpassword, $this->server, 'UTF8') : (($this->persistency) ? @ociplogon($this->user, $sqlpassword, $this->server, 'UTF8') : @ocinlogon($this->user, $sqlpassword, $this->server, 'UTF8'));
|
||||
|
||||
return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class dbal_postgres extends dbal
|
||||
/**
|
||||
* Connect to server
|
||||
*/
|
||||
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
|
||||
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
|
||||
{
|
||||
$connect_string = '';
|
||||
|
||||
@ -70,7 +70,7 @@ class dbal_postgres extends dbal
|
||||
|
||||
$this->persistency = $persistency;
|
||||
|
||||
$this->db_connect_id = ($this->persistency) ? @pg_pconnect($connect_string) : @pg_connect($connect_string);
|
||||
$this->db_connect_id = ($this->persistency) ? @pg_pconnect($connect_string, $new_link) : @pg_connect($connect_string, $new_link);
|
||||
|
||||
return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class dbal_sqlite extends dbal
|
||||
/**
|
||||
* Connect to server
|
||||
*/
|
||||
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
|
||||
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
|
||||
{
|
||||
$this->persistency = $persistency;
|
||||
$this->user = $sqluser;
|
||||
|
@ -257,7 +257,7 @@ function connect_check_db($error_connect, &$error, $dbms, $table_prefix, $dbhost
|
||||
}
|
||||
|
||||
// Try and connect ...
|
||||
if (is_array($db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false)))
|
||||
if (is_array($db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true)))
|
||||
{
|
||||
$db_error = $db->sql_error();
|
||||
$error[] = $lang['INST_ERR_DB_CONNECT'] . '<br />' . (($db_error['message']) ? $db_error['message'] : $lang['INST_ERR_DB_NO_ERROR']);
|
||||
|
@ -126,7 +126,7 @@ class install_convert extends module
|
||||
require($phpbb_root_path . 'includes/functions_convert.' . $phpEx);
|
||||
|
||||
$db = new $sql_db();
|
||||
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false);
|
||||
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true);
|
||||
unset($dbpasswd);
|
||||
|
||||
// We need to fill the config to let internal functions correctly work
|
||||
@ -222,7 +222,7 @@ class install_convert extends module
|
||||
require($phpbb_root_path . 'includes/functions_convert.' . $phpEx);
|
||||
|
||||
$db = new $sql_db();
|
||||
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false);
|
||||
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true);
|
||||
unset($dbpasswd);
|
||||
|
||||
switch ($db->sql_layer)
|
||||
@ -331,7 +331,7 @@ class install_convert extends module
|
||||
require($phpbb_root_path . 'includes/functions_convert.' . $phpEx);
|
||||
|
||||
$db = new $sql_db();
|
||||
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false);
|
||||
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true);
|
||||
unset($dbpasswd);
|
||||
|
||||
$this->page_title = $lang['STAGE_SETTINGS'];
|
||||
@ -427,7 +427,7 @@ class install_convert extends module
|
||||
{
|
||||
$sql_db = 'dbal_' . $src_dbms;
|
||||
$src_db = new $sql_db();
|
||||
$src_db->sql_connect($src_dbhost, $src_dbuser, $src_dbpasswd, $src_dbname, $src_dbport, false);
|
||||
$src_db->sql_connect($src_dbhost, $src_dbuser, $src_dbpasswd, $src_dbname, $src_dbport, false, true);
|
||||
$same_db = false;
|
||||
}
|
||||
else
|
||||
@ -466,7 +466,7 @@ class install_convert extends module
|
||||
compare_table($tables, $tablename, $prefixes);
|
||||
}
|
||||
}
|
||||
$src_->sql_freeresult($result);
|
||||
$src_db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
foreach ($prefixes as $prefix => $count)
|
||||
@ -591,7 +591,7 @@ class install_convert extends module
|
||||
require($phpbb_root_path . 'includes/functions_convert.' . $phpEx);
|
||||
|
||||
$db = new $sql_db();
|
||||
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false);
|
||||
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true);
|
||||
unset($dbpasswd);
|
||||
|
||||
$sql = 'SELECT *
|
||||
@ -663,7 +663,7 @@ class install_convert extends module
|
||||
}
|
||||
$sql_db = 'dbal_' . $convert->src_dbms;
|
||||
$src_db = new $sql_db();
|
||||
$src_db->sql_connect($convert->src_dbhost, $convert->src_dbuser, $convert->src_dbpasswd, $convert->src_dbname, $convert->src_dbport, false);
|
||||
$src_db->sql_connect($convert->src_dbhost, $convert->src_dbuser, $convert->src_dbpasswd, $convert->src_dbname, $convert->src_dbport, false, true);
|
||||
$same_db = false;
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user