diff options
| author | Paul S. Owen <psotfx@users.sourceforge.net> | 2001-11-20 22:34:50 +0000 |
|---|---|---|
| committer | Paul S. Owen <psotfx@users.sourceforge.net> | 2001-11-20 22:34:50 +0000 |
| commit | 8acc3cff9a0ba872b3ee0ca13c87fefebb4e500b (patch) | |
| tree | 9e07da3303264fc511dfd86c76a9fe8e0773549e /phpBB/db | |
| parent | 4a6c3a5ec0628d8594df97f1186ec086ee53731e (diff) | |
| download | forums-8acc3cff9a0ba872b3ee0ca13c87fefebb4e500b.tar forums-8acc3cff9a0ba872b3ee0ca13c87fefebb4e500b.tar.gz forums-8acc3cff9a0ba872b3ee0ca13c87fefebb4e500b.tar.bz2 forums-8acc3cff9a0ba872b3ee0ca13c87fefebb4e500b.tar.xz forums-8acc3cff9a0ba872b3ee0ca13c87fefebb4e500b.zip | |
Some updates, uses TOP rather than two ROWCOUNT queries for LIMIT
git-svn-id: file:///svn/phpbb/trunk@1396 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/db')
| -rw-r--r-- | phpBB/db/mssql.php | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/phpBB/db/mssql.php b/phpBB/db/mssql.php index 77fe808833..c0759d3379 100644 --- a/phpBB/db/mssql.php +++ b/phpBB/db/mssql.php @@ -88,7 +88,7 @@ class sql_db // if( $this->in_transaction ) { - mssql_query("COMMIT", $this->db_connect_id); + @mssql_query("COMMIT", $this->db_connect_id); } $result = @mssql_close($this->db_connect_id); return $result; @@ -116,7 +116,7 @@ class sql_db $this->num_queries++; if($transaction == BEGIN_TRANSACTION) { - $result = mssql_query("BEGIN TRANSACTION", $this->db_connect_id); + $result = @mssql_query("BEGIN TRANSACTION", $this->db_connect_id); if(!$result) { return false; @@ -136,9 +136,9 @@ class sql_db // returns something then there's a problem. This may well be a false assumption though // ... needs checking under Windows itself. // - if(eregi("LIMIT", $query)) + if( preg_match("/^SELECT.*?LIMIT/is", $query) ) { - preg_match("/^(.*)LIMIT ([0-9]+)[, ]*([0-9]+)*/s", $query, $limits); + preg_match("/^SELECT(.*)LIMIT ([0-9]+)[, ]*([0-9]+)*$/s", $query, $limits); $query = $limits[1]; if($limits[3]) @@ -152,13 +152,11 @@ class sql_db $num_rows = $limits[2]; } -// $this->query_array[] = $query; - - @mssql_query("SET ROWCOUNT ".($row_offset + $num_rows)); + $query = "SELECT TOP " . ($row_offset + $num_rows) . $query; +// @mssql_query("SET ROWCOUNT ".($row_offset + $num_rows)); $this->query_result = @mssql_query($query, $this->db_connect_id); - - @mssql_query("SET ROWCOUNT 0"); +// @mssql_query("SET ROWCOUNT 0"); $this->query_limit_success[$this->query_result] = true; @@ -177,8 +175,6 @@ class sql_db } else if(eregi("^INSERT ", $query)) { -// $this->query_array[] = $query; - $query = preg_replace("/\\\'/s", "''", $query); $this->query_result = @mssql_query($query, $this->db_connect_id); @@ -192,7 +188,7 @@ class sql_db { if($this->in_transaction) { - mssql_query("ROLLBACK", $this->db_connect_id); + @mssql_query("ROLLBACK", $this->db_connect_id); $this->in_transaction = FALSE; } return false; @@ -203,8 +199,6 @@ class sql_db } else { -// $this->query_array[] = $query; - if(eregi("SELECT", $query)) { $this->query_result = @mssql_query($query, $this->db_connect_id); @@ -233,16 +227,16 @@ class sql_db { if($this->in_transaction) { - mssql_query("ROLLBACK", $this->db_connect_id); + @mssql_query("ROLLBACK", $this->db_connect_id); $this->in_transaction = FALSE; } return false; } } - if($transaction == END_TRANSACTION) + if($transaction == END_TRANSACTION && $this->in_transaction) { - $result = mssql_query("COMMIT", $this->db_connect_id); + $result = @mssql_query("COMMIT", $this->db_connect_id); $this->in_transaction = FALSE; } @@ -252,7 +246,7 @@ class sql_db { if($transaction == END_TRANSACTION) { - $result = mssql_query("COMMIT", $this->db_connect_id); + $result = @mssql_query("COMMIT", $this->db_connect_id); $this->in_transaction = FALSE; } |
