aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorDavid M <davidmj@users.sourceforge.net>2007-02-19 04:12:13 +0000
committerDavid M <davidmj@users.sourceforge.net>2007-02-19 04:12:13 +0000
commit1d6fd8e1352d9ed4bfe3f91e9f2bf254920eb479 (patch)
tree25f60a7da04cd07ff1ea78c0e7b12a157766986e /phpBB
parent0350eb9f3ca0f7f239ae868afef4e7765a22833b (diff)
downloadforums-1d6fd8e1352d9ed4bfe3f91e9f2bf254920eb479.tar
forums-1d6fd8e1352d9ed4bfe3f91e9f2bf254920eb479.tar.gz
forums-1d6fd8e1352d9ed4bfe3f91e9f2bf254920eb479.tar.bz2
forums-1d6fd8e1352d9ed4bfe3f91e9f2bf254920eb479.tar.xz
forums-1d6fd8e1352d9ed4bfe3f91e9f2bf254920eb479.zip
- 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
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/common.php2
-rw-r--r--phpBB/includes/db/dbal.php7
-rw-r--r--phpBB/includes/db/firebird.php10
-rw-r--r--phpBB/includes/db/mssql.php14
-rw-r--r--phpBB/includes/db/mssql_odbc.php8
-rw-r--r--phpBB/includes/db/mysql.php6
-rw-r--r--phpBB/includes/db/mysqli.php2
-rw-r--r--phpBB/includes/db/oracle.php4
-rw-r--r--phpBB/includes/db/postgres.php4
-rw-r--r--phpBB/includes/db/sqlite.php2
-rw-r--r--phpBB/includes/functions_install.php2
-rw-r--r--phpBB/install/install_convert.php14
12 files changed, 36 insertions, 39 deletions
diff --git a/phpBB/common.php b/phpBB/common.php
index 2d1d67c3fc..3ee931e95d 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -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);
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php
index da649ed812..77b5b46ffc 100644
--- a/phpBB/includes/db/dbal.php
+++ b/phpBB/includes/db/dbal.php
@@ -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();
diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php
index 5ce4949956..317054d978 100644
--- a/phpBB/includes/db/firebird.php
+++ b/phpBB/includes/db/firebird.php
@@ -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;
}
}
diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php
index 6429d4be41..0af6514322 100644
--- a/phpBB/includes/db/mssql.php
+++ b/phpBB/includes/db/mssql.php
@@ -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)
diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php
index 0b8f1e2a95..ab3bd2a164 100644
--- a/phpBB/includes/db/mssql_odbc.php
+++ b/phpBB/includes/db/mssql_odbc.php
@@ -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)
diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php
index b750618ae6..2eb3a561bc 100644
--- a/phpBB/includes/db/mysql.php
+++ b/phpBB/includes/db/mysql.php
@@ -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);
diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php
index da6faa3983..3149349411 100644
--- a/phpBB/includes/db/mysqli.php
+++ b/phpBB/includes/db/mysqli.php
@@ -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;
diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php
index 4195bcfe52..1920ce8fc1 100644
--- a/phpBB/includes/db/oracle.php
+++ b/phpBB/includes/db/oracle.php
@@ -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('');
}
diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php
index f2e96260ba..3f0c97ce00 100644
--- a/phpBB/includes/db/postgres.php
+++ b/phpBB/includes/db/postgres.php
@@ -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('');
}
diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/sqlite.php
index 9f44bd6b35..8a50c546a7 100644
--- a/phpBB/includes/db/sqlite.php
+++ b/phpBB/includes/db/sqlite.php
@@ -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;
diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php
index 30d14c985b..0906e5e1b1 100644
--- a/phpBB/includes/functions_install.php
+++ b/phpBB/includes/functions_install.php
@@ -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']);
diff --git a/phpBB/install/install_convert.php b/phpBB/install/install_convert.php
index 9b7e621397..ffbb4e4ef7 100644
--- a/phpBB/install/install_convert.php
+++ b/phpBB/install/install_convert.php
@@ -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