diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2006-06-02 13:26:27 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2006-06-02 13:26:27 +0000 |
commit | 7d264396df47c17675dd70601a19cb3a06a45ff0 (patch) | |
tree | 7928c9d030305706bd31032e208d99ee640b2d50 /phpBB/includes | |
parent | b087e60113187114ea79ac34184ace96e7bf0a80 (diff) | |
download | forums-7d264396df47c17675dd70601a19cb3a06a45ff0.tar forums-7d264396df47c17675dd70601a19cb3a06a45ff0.tar.gz forums-7d264396df47c17675dd70601a19cb3a06a45ff0.tar.bz2 forums-7d264396df47c17675dd70601a19cb3a06a45ff0.tar.xz forums-7d264396df47c17675dd70601a19cb3a06a45ff0.zip |
some adjustments
nils: please have a look at the @todo comment in mcp_queue.php
git-svn-id: file:///svn/phpbb/trunk@6002 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/db/dbal.php | 17 | ||||
-rw-r--r-- | phpBB/includes/db/firebird.php | 44 | ||||
-rw-r--r-- | phpBB/includes/db/mssql.php | 28 | ||||
-rw-r--r-- | phpBB/includes/db/mssql_odbc.php | 29 | ||||
-rw-r--r-- | phpBB/includes/db/mysql.php | 29 | ||||
-rw-r--r-- | phpBB/includes/db/mysql4.php | 31 | ||||
-rw-r--r-- | phpBB/includes/db/mysqli.php | 29 | ||||
-rw-r--r-- | phpBB/includes/db/oracle.php | 29 | ||||
-rw-r--r-- | phpBB/includes/db/postgres.php | 24 | ||||
-rw-r--r-- | phpBB/includes/db/sqlite.php | 23 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_queue.php | 5 |
11 files changed, 134 insertions, 154 deletions
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index 2d8d2e7624..02072c1c60 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -225,17 +225,7 @@ class dbal case 'SELECT': case 'SELECT_DISTINCT'; - if ($query == 'SELECT_DISTINCT') - { - $sql .= 'SELECT DISTINCT'; - } - else - { - $sql .= 'SELECT'; - } - - $sql .= ' ' . $array['SELECT']; - $sql .= ' FROM '; + $sql = str_replace('_', ' ', $query) . ' ' . $array['SELECT'] . ' FROM '; $table_array = array(); foreach ($array['FROM'] as $table_name => $alias) @@ -270,6 +260,7 @@ class dbal break; } + return $sql; } @@ -316,7 +307,7 @@ class dbal { $this->sql_transaction('rollback'); } - + if (strlen($message) > 1024) { // We need to define $msg_long_text here to circumvent text stripping. @@ -487,8 +478,6 @@ class dbal $this->_sql_report($mode, $query); -// $this->num_queries['cache']++; - break; case 'record_fromcache': diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php index c876483a2b..61d76e275c 100644 --- a/phpBB/includes/db/firebird.php +++ b/phpBB/includes/db/firebird.php @@ -58,7 +58,7 @@ class dbal_firebird extends dbal case 'begin': $result = true; $this->transaction = true; - break; + break; case 'commit': $result = @ibase_commit(); @@ -68,12 +68,12 @@ class dbal_firebird extends dbal { @ibase_rollback(); } - break; + break; case 'rollback': $result = @ibase_rollback(); $this->transaction = false; - break; + break; default: $result = true; @@ -91,7 +91,6 @@ class dbal_firebird extends dbal { global $cache; - $this->last_query_text = $query; $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; $this->sql_add_num_queries($this->query_result); @@ -103,7 +102,6 @@ class dbal_firebird extends dbal $this->sql_error($query); } - // TODO: have to debug the commit states in firebird if (!$this->transaction) { @ibase_commit_ret(); @@ -132,19 +130,19 @@ class dbal_firebird extends dbal * Build LIMIT query */ function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - if ($query != '') + { + if ($query != '') { - $this->query_result = false; + $this->query_result = false; $query = 'SELECT FIRST ' . $total . ((!empty($offset)) ? ' SKIP ' . $offset : '') . substr($query, 6); return $this->sql_query($query, $cache_ttl); - } - else - { - return false; - } + } + else + { + return false; + } } /** @@ -222,7 +220,7 @@ class dbal_firebird extends dbal { $this->sql_rowseek($rownum, $query_id); } - + $row = $this->sql_fetchrow($query_id); return isset($row[$field]) ? $row[$field] : false; } @@ -241,16 +239,6 @@ class dbal_firebird extends dbal $query_id = $this->query_result; } -/* - $this->sql_freeresult($query_id); - $query_id = $this->sql_query($this->last_query_text); - - if (!$query_id) - { - return false; - } -*/ - // We do not fetch the row for rownum == 0 because then the next resultset would be the second row for ($i = 0; $i < $rownum; $i++) { @@ -274,9 +262,9 @@ class dbal_firebird extends dbal { if ($this->query_result && preg_match('#^INSERT[\t\n ]+INTO[\t\n ]+([a-z0-9\_\-]+)#is', $this->last_query_text, $tablename)) { - $query = "SELECT GEN_ID(" . $tablename[1] . "_gen, 0) AS new_id - FROM RDB\$DATABASE"; - if (!($temp_q_id = @ibase_query($this->db_connect_id, $query))) + $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; } @@ -287,7 +275,7 @@ class dbal_firebird extends dbal return ($temp_result) ? $temp_result->NEW_ID : false; } } - + return false; } diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php index 2f16d6cf22..c700525577 100644 --- a/phpBB/includes/db/mssql.php +++ b/phpBB/includes/db/mssql.php @@ -65,7 +65,7 @@ class dbal_mssql extends dbal case 'begin': $result = @mssql_query('BEGIN TRANSACTION', $this->db_connect_id); $this->transaction = true; - break; + break; case 'commit': $result = @mssql_query('commit', $this->db_connect_id); @@ -75,12 +75,12 @@ class dbal_mssql extends dbal { @mssql_query('ROLLBACK', $this->db_connect_id); } - break; + break; case 'rollback': $result = @mssql_query('ROLLBACK', $this->db_connect_id); $this->transaction = false; - break; + break; default: $result = true; @@ -146,10 +146,10 @@ class dbal_mssql extends dbal * Build LIMIT query */ function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - if ($query != '') + { + if ($query != '') { - $this->query_result = false; + $this->query_result = false; // if $total is set to 0 we do not want to limit the number of rows if ($total == 0) @@ -170,11 +170,11 @@ class dbal_mssql extends dbal } return $this->sql_query($query, $cache_ttl); - } - else - { - return false; - } + } + else + { + return false; + } } /** @@ -217,7 +217,7 @@ class dbal_mssql extends dbal } $row = @mssql_fetch_assoc($query_id); - + // I hope i am able to remove this later... hopefully only a PHP or MSSQL bug if ($row) { @@ -247,11 +247,11 @@ class dbal_mssql extends dbal { $this->sql_rowseek($rownum, $query_id); } - + $row = $this->sql_fetchrow($query_id); return isset($row[$field]) ? $row[$field] : false; } - + return false; } diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php index 55e1608d89..4ae5339a62 100644 --- a/phpBB/includes/db/mssql_odbc.php +++ b/phpBB/includes/db/mssql_odbc.php @@ -59,7 +59,7 @@ class dbal_mssql_odbc extends dbal case 'begin': $result = @odbc_autocommit($this->db_connect_id, false); $this->transaction = true; - break; + break; case 'commit': $result = @odbc_commit($this->db_connect_id); @@ -71,13 +71,13 @@ class dbal_mssql_odbc extends dbal @odbc_rollback($this->db_connect_id); @odbc_autocommit($this->db_connect_id, true); } - break; + break; case 'rollback': $result = @odbc_rollback($this->db_connect_id); @odbc_autocommit($this->db_connect_id, true); $this->transaction = false; - break; + break; default: $result = true; @@ -100,7 +100,6 @@ class dbal_mssql_odbc extends dbal { $this->sql_report('start', $query); } - $this->last_query_text = $query; $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; @@ -145,10 +144,10 @@ class dbal_mssql_odbc extends dbal * Build LIMIT query */ function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - if ($query != '') + { + if ($query != '') { - $this->query_result = false; + $this->query_result = false; // if $total is set to 0 we do not want to limit the number of rows if ($total == 0) @@ -168,12 +167,12 @@ class dbal_mssql_odbc extends dbal $query = 'SELECT TOP ' . ($row_offset + $num_rows) . ' ' . substr($query, 6); } - return $this->sql_query($query, $cache_ttl); - } - else - { - return false; - } + return $this->sql_query($query, $cache_ttl); + } + else + { + return false; + } } /** @@ -214,7 +213,7 @@ class dbal_mssql_odbc extends dbal { return $cache->sql_fetchrow($query_id); } - + return ($query_id) ? @odbc_fetch_array($query_id) : false; } @@ -235,7 +234,7 @@ class dbal_mssql_odbc extends dbal { $this->sql_rowseek($rownum, $query_id); } - + $row = $this->sql_fetchrow($query_id); return isset($row[$field]) ? $row[$field] : false; } diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index 8fc9e2a04b..c31132b990 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -65,7 +65,7 @@ class dbal_mysql extends dbal case 'begin': $result = @mysql_query('BEGIN', $this->db_connect_id); $this->transaction = true; - break; + break; case 'commit': $result = @mysql_query('COMMIT', $this->db_connect_id); @@ -75,12 +75,12 @@ class dbal_mysql extends dbal { @mysql_query('ROLLBACK', $this->db_connect_id); } - break; + break; case 'rollback': $result = @mysql_query('ROLLBACK', $this->db_connect_id); $this->transaction = false; - break; + break; default: $result = true; @@ -146,10 +146,10 @@ class dbal_mysql extends dbal * Build LIMIT query */ function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - if ($query != '') + { + if ($query != '') { - $this->query_result = false; + $this->query_result = false; // if $total is set to 0 we do not want to limit the number of rows if ($total == 0) @@ -159,12 +159,12 @@ class dbal_mysql extends dbal $query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total); - return $this->sql_query($query, $cache_ttl); - } - else - { - return false; - } + return $this->sql_query($query, $cache_ttl); + } + else + { + return false; + } } /** @@ -302,9 +302,10 @@ class dbal_mysql extends dbal $data = '(' . $data . ')'; break; } + return $data; } - + /** * return sql error array * @private @@ -318,7 +319,7 @@ class dbal_mysql extends dbal 'code' => @mysql_errno() ); } - + return array( 'message' => @mysql_error($this->db_connect_id), 'code' => @mysql_errno($this->db_connect_id) diff --git a/phpBB/includes/db/mysql4.php b/phpBB/includes/db/mysql4.php index ac896ce78f..26da6432c1 100644 --- a/phpBB/includes/db/mysql4.php +++ b/phpBB/includes/db/mysql4.php @@ -67,22 +67,22 @@ class dbal_mysql4 extends dbal case 'begin': $result = @mysql_query('BEGIN', $this->db_connect_id); $this->transaction = true; - break; + break; case 'commit': $result = @mysql_query('COMMIT', $this->db_connect_id); $this->transaction = false; - + if (!$result) { @mysql_query('ROLLBACK', $this->db_connect_id); } - break; + break; case 'rollback': $result = @mysql_query('ROLLBACK', $this->db_connect_id); $this->transaction = false; - break; + break; default: $result = true; @@ -148,10 +148,10 @@ class dbal_mysql4 extends dbal * Build LIMIT query */ function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - if ($query != '') + { + if ($query != '') { - $this->query_result = false; + $this->query_result = false; // if $total is set to 0 we do not want to limit the number of rows if ($total == 0) @@ -162,12 +162,12 @@ class dbal_mysql4 extends dbal $query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total); - return $this->sql_query($query, $cache_ttl); - } - else - { - return false; - } + return $this->sql_query($query, $cache_ttl); + } + else + { + return false; + } } /** @@ -289,7 +289,7 @@ class dbal_mysql4 extends dbal { return @mysql_real_escape_string($msg); } - + return @mysql_real_escape_string($msg, $this->db_connect_id); } @@ -305,6 +305,7 @@ class dbal_mysql4 extends dbal $data = '(' . $data . ')'; break; } + return $data; } @@ -321,7 +322,7 @@ class dbal_mysql4 extends dbal 'code' => @mysql_errno() ); } - + return array( 'message' => @mysql_error($this->db_connect_id), 'code' => @mysql_errno($this->db_connect_id) diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php index 79230b178a..1a969684a2 100644 --- a/phpBB/includes/db/mysqli.php +++ b/phpBB/includes/db/mysqli.php @@ -67,7 +67,7 @@ class dbal_mysqli extends dbal case 'begin': $result = @mysqli_autocommit($this->db_connect_id, false); $this->transaction = true; - break; + break; case 'commit': $result = @mysqli_commit($this->db_connect_id); @@ -79,13 +79,13 @@ class dbal_mysqli extends dbal @mysqli_rollback($this->db_connect_id); @mysqli_autocommit($this->db_connect_id, true); } - break; + break; case 'rollback': $result = @mysqli_rollback($this->db_connect_id); @mysqli_autocommit($this->db_connect_id, true); $this->transaction = false; - break; + break; default: $result = true; @@ -146,10 +146,10 @@ class dbal_mysqli extends dbal * Build LIMIT query */ function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - if ($query != '') + { + if ($query != '') { - $this->query_result = false; + $this->query_result = false; // if $total is set to 0 we do not want to limit the number of rows if ($total == 0) @@ -160,12 +160,12 @@ class dbal_mysqli extends dbal $query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total); - return $this->sql_query($query, $cache_ttl); - } - else - { - return false; - } + return $this->sql_query($query, $cache_ttl); + } + else + { + return false; + } } /** @@ -227,7 +227,7 @@ class dbal_mysqli extends dbal { $this->sql_rowseek($rownum, $query_id); } - + $row = $this->sql_fetchrow($query_id); return isset($row[$field]) ? $row[$field] : false; } @@ -296,9 +296,10 @@ class dbal_mysqli extends dbal $data = '(' . $data . ')'; break; } + return $data; } - + /** * return sql error array * @private diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php index f2499c5456..d9a7298c04 100644 --- a/phpBB/includes/db/oracle.php +++ b/phpBB/includes/db/oracle.php @@ -57,7 +57,7 @@ class dbal_oracle extends dbal case 'begin': $result = true; $this->transaction = true; - break; + break; case 'commit': $result = @ocicommit($this->db_connect_id); @@ -67,12 +67,12 @@ class dbal_oracle extends dbal { @ocirollback($this->db_connect_id); } - break; + break; case 'rollback': $result = @ocirollback($this->db_connect_id); $this->transaction = false; - break; + break; default: $result = true; @@ -90,13 +90,12 @@ class dbal_oracle extends dbal { global $cache; - // EXPLAIN only in extra debug mode if (defined('DEBUG_EXTRA')) { $this->sql_report('start', $query); } - + $this->last_query_text = $query; $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; $this->sql_add_num_queries($this->query_result); @@ -128,7 +127,7 @@ class dbal_oracle extends dbal $this->sql_transaction('commit'); } } - + if (defined('DEBUG_EXTRA')) { $this->sql_report('stop', $query); @@ -161,19 +160,19 @@ class dbal_oracle extends dbal * Build LIMIT query */ function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - if ($query != '') + { + if ($query != '') { $this->query_result = false; $query = 'SELECT * FROM (SELECT /*+ FIRST_ROWS */ rownum AS xrownum, a.* FROM (' . $query . ') a WHERE rownum <= ' . ($offset + $total) . ') WHERE xrownum >= ' . $offset; return $this->sql_query($query, $cache_ttl); - } - else - { + } + else + { return false; - } + } } /** @@ -220,7 +219,7 @@ class dbal_oracle extends dbal { return $cache->sql_fetchrow($query_id); } - + $row = array(); $result = @ocifetchinto($query_id, $row, OCI_ASSOC + OCI_RETURN_NULLS); @@ -261,11 +260,11 @@ class dbal_oracle extends dbal { $this->sql_rowseek($rownum, $query_id); } - + $row = $this->sql_fetchrow($query_id); return isset($row[$field]) ? $row[$field] : false; } - + return false; } diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php index f9c2cd1388..fbb113178a 100644 --- a/phpBB/includes/db/postgres.php +++ b/phpBB/includes/db/postgres.php @@ -94,7 +94,7 @@ class dbal_postgres extends dbal case 'begin': $result = @pg_query($this->db_connect_id, 'BEGIN'); $this->transaction = true; - break; + break; case 'commit': $result = @pg_query($this->db_connect_id, 'COMMIT'); @@ -104,12 +104,12 @@ class dbal_postgres extends dbal { @pg_query($this->db_connect_id, 'ROLLBACK'); } - break; + break; case 'rollback': $result = @pg_query($this->db_connect_id, 'ROLLBACK'); $this->transaction = false; - break; + break; default: $result = true; @@ -127,7 +127,6 @@ class dbal_postgres extends dbal { global $cache; - // EXPLAIN only in extra debug mode if (defined('DEBUG_EXTRA')) { @@ -187,7 +186,7 @@ class dbal_postgres extends dbal */ function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) { - if ($query != '') + if ($query != '') { $this->query_result = false; @@ -200,11 +199,11 @@ class dbal_postgres extends dbal $query .= "\n LIMIT $total OFFSET $offset"; return $this->sql_query($query, $cache_ttl); - } - else - { + } + else + { return false; - } + } } /** @@ -266,7 +265,7 @@ class dbal_postgres extends dbal { $this->sql_rowseek($rownum, $query_id); } - + $row = $this->sql_fetchrow($query_id); return isset($row[$field]) ? $row[$field] : false; } @@ -301,6 +300,7 @@ class dbal_postgres extends dbal { $query = "SELECT currval('" . $tablename[1] . "_seq') AS last_value"; $temp_q_id = @pg_query($this->db_connect_id, $query); + if (!$temp_q_id) { return false; @@ -325,7 +325,7 @@ class dbal_postgres extends dbal { $query_id = $this->query_result; } - + if (isset($this->open_queries[(int) $query_id])) { unset($this->open_queries[(int) $query_id]); @@ -337,10 +337,10 @@ class dbal_postgres extends dbal /** * Escape string used in sql query + * Note: Do not use for bytea values if we may use them at a later stage */ function sql_escape($msg) { - // Do not use for bytea values return @pg_escape_string($msg); } diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/sqlite.php index 85c6986c79..0bfe9a40ca 100644 --- a/phpBB/includes/db/sqlite.php +++ b/phpBB/includes/db/sqlite.php @@ -61,7 +61,7 @@ class dbal_sqlite extends dbal case 'begin': $result = @sqlite_query('BEGIN', $this->db_connect_id); $this->transaction = true; - break; + break; case 'commit': $result = @sqlite_query('COMMIT', $this->db_connect_id); @@ -71,12 +71,12 @@ class dbal_sqlite extends dbal { @sqlite_query('ROLLBACK', $this->db_connect_id); } - break; + break; case 'rollback': $result = @sqlite_query('ROLLBACK', $this->db_connect_id); $this->transaction = false; - break; + break; default: $result = true; @@ -94,7 +94,6 @@ class dbal_sqlite extends dbal { global $cache; - // EXPLAIN only in extra debug mode if (defined('DEBUG_EXTRA')) { @@ -143,8 +142,8 @@ class dbal_sqlite extends dbal * Build LIMIT query */ function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - if ($query != '') + { + if ($query != '') { $this->query_result = false; @@ -157,11 +156,11 @@ class dbal_sqlite extends dbal $query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total); return $this->sql_query($query, $cache_ttl); - } - else - { - return false; - } + } + else + { + return false; + } } /** @@ -225,7 +224,7 @@ class dbal_sqlite extends dbal } else { - @sqlite_seek($query_id, $rownum); + $this->sql_rowseek($rownum, $query_id); return @sqlite_column($query_id, $field); } } diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 9e7da838b5..c202637092 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -367,7 +367,10 @@ function approve_post($post_id_list, $mode) $topic_id_list[$post_data['topic_id']] = 1; // Topic or Post. ;) - if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_last_post_id'] == $post_id) + /** + * @todo What happens if a user posts a new topic which is not approved, then a second user replies and the post is automatically approved ;) + */ + if ($post_data['topic_first_post_id'] == $post_id/* && $post_data['topic_last_post_id'] == $post_id*/) { if ($post_data['forum_id']) { |