aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/db
diff options
context:
space:
mode:
authorDavid M <davidmj@users.sourceforge.net>2007-05-05 04:53:43 +0000
committerDavid M <davidmj@users.sourceforge.net>2007-05-05 04:53:43 +0000
commitdfe674ffa12a77468ef2663d75d67768ee219039 (patch)
tree1b70dd9b08eaa2798eb3a3dbd3085fc699c40e66 /phpBB/includes/db
parent65fe2e0e367e0bd9acf3f3db377874ad57731e8c (diff)
downloadforums-dfe674ffa12a77468ef2663d75d67768ee219039.tar
forums-dfe674ffa12a77468ef2663d75d67768ee219039.tar.gz
forums-dfe674ffa12a77468ef2663d75d67768ee219039.tar.bz2
forums-dfe674ffa12a77468ef2663d75d67768ee219039.tar.xz
forums-dfe674ffa12a77468ef2663d75d67768ee219039.zip
- changed the way we do forum accounting in phpBB, far less intensive and much faster. sync() recalculates the number of topics and posts using just the topics table instead of having to join topics and posts together. However, even this can be avoided if we know what operation is happening and an auto sync is not in action. Since MCP operations are "known", we can provide very fast MCP operations.
- changed the way we decide if a DB gets multi value support. Old method uses switch/case, new method assumes a DB can't unless the DB says it can via a property I hope nothing is broken :P git-svn-id: file:///svn/phpbb/trunk@7466 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/db')
-rw-r--r--phpBB/includes/db/dbal.php31
-rw-r--r--phpBB/includes/db/mysql.php1
-rw-r--r--phpBB/includes/db/mysqli.php2
-rw-r--r--phpBB/includes/db/postgres.php38
4 files changed, 42 insertions, 30 deletions
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php
index dbc0859733..cfd13fd118 100644
--- a/phpBB/includes/db/dbal.php
+++ b/phpBB/includes/db/dbal.php
@@ -38,6 +38,9 @@ class dbal
// Holding the last sql query on sql error
var $sql_error_sql = '';
+ // Supports multi inserts?
+ var $multi_insert = false;
+
/**
* Current sql layer
*/
@@ -364,25 +367,21 @@ class dbal
return false;
}
- switch ($this->sql_layer)
+ if ($this->multi_insert)
{
- case 'mysql':
- case 'mysql4':
- case 'mysqli':
- $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('MULTI_INSERT', $sql_ary));
- break;
-
- default:
- foreach ($sql_ary as $ary)
+ $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('MULTI_INSERT', $sql_ary));
+ }
+ else
+ {
+ foreach ($sql_ary as $ary)
+ {
+ if (!is_array($ary))
{
- if (!is_array($ary))
- {
- return false;
- }
-
- $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $ary));
+ return false;
}
- break;
+
+ $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $ary));
+ }
}
return true;
diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php
index dfa4823a87..c20e73315a 100644
--- a/phpBB/includes/db/mysql.php
+++ b/phpBB/includes/db/mysql.php
@@ -30,6 +30,7 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
class dbal_mysql extends dbal
{
var $mysql_version;
+ var $multi_insert = true;
/**
* Connect to server
diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php
index c03c117085..6f54b5c8b3 100644
--- a/phpBB/includes/db/mysqli.php
+++ b/phpBB/includes/db/mysqli.php
@@ -26,6 +26,8 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
*/
class dbal_mysqli extends dbal
{
+ var $multi_insert = true;
+
/**
* Connect to server
*/
diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php
index bdaab439ea..94bc70fa6a 100644
--- a/phpBB/includes/db/postgres.php
+++ b/phpBB/includes/db/postgres.php
@@ -26,6 +26,7 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
class dbal_postgres extends dbal
{
var $last_query_text = '';
+ var $pgsql_version;
/**
* Connect to server
@@ -80,6 +81,28 @@ class dbal_postgres extends dbal
if ($this->db_connect_id)
{
+ // determine what version of PostgreSQL is running, we can be more efficient if they are running 8.2+
+ if (version_compare(PHP_VERSION, '5.0.0', '>='))
+ {
+ $this->pgsql_version = @pg_parameter_status($this->db_connect_id, 'server_version');
+ }
+ else
+ {
+ $query_id = @pg_query($this->db_connect_id, 'SELECT VERSION()');
+ $row = @pg_fetch_assoc($query_id, null);
+ @pg_free_result($query_id);
+
+ if (!empty($row['version']))
+ {
+ $this->pgsql_version = substr($row['version'], 10);
+ }
+ }
+
+ if (!empty($this->pgsql_version) && $this->pgsql_version[0] >= '8' && $this->pgsql_version[2] >= '2')
+ {
+ $this->multi_insert = true;
+ }
+
if ($schema !== '')
{
@pg_query($this->db_connect_id, 'SET search_path TO ' . $schema);
@@ -95,20 +118,7 @@ class dbal_postgres extends dbal
*/
function sql_server_info()
{
- if (version_compare(PHP_VERSION, '5.0.0', '>='))
- {
- $version = @pg_version($this->db_connect_id);
- return 'PostgreSQL' . ((!empty($version)) ? ' ' . $version['client'] : '');
- }
- else
- {
- $query_id = @pg_query($this->db_connect_id, 'select version()');
- $row = @pg_fetch_assoc($query_id, null);
- @pg_free_result($query_id);
-
- $version = $row['version'];
- return ((!empty($version)) ? ' ' . $version : '');
- }
+ return 'PostgreSQL ' . $this->pgsql_version;
}
/**