mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
Fixed LIMIT and other issues
git-svn-id: file:///svn/phpbb/trunk@292 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
03923a2665
commit
60c507756c
1 changed files with 23 additions and 14 deletions
|
@ -4,7 +4,7 @@
|
||||||
* -------------------
|
* -------------------
|
||||||
* begin : Saturday, Feb 13, 2001
|
* begin : Saturday, Feb 13, 2001
|
||||||
* copyright : (C) 2001 The phpBB Group
|
* copyright : (C) 2001 The phpBB Group
|
||||||
* email : support@phpbb.com
|
* email : supportphpbb.com
|
||||||
*
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
|
@ -49,17 +49,19 @@ class sql_db
|
||||||
}
|
}
|
||||||
if($sqlserver)
|
if($sqlserver)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(ereg(":",$sqlserver))
|
if(ereg(":",$sqlserver))
|
||||||
{
|
{
|
||||||
list($sqlserver,$sqlport) = split(":",$sqlserver);
|
list($sqlserver,$sqlport) = split(":",$sqlserver);
|
||||||
$this->connect_string .= "host=$sqlserver port=$sqlport ";
|
$this->connect_string .= "host=$sqlserver port=$sqlport ";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if($sqlserver != "localhost")
|
||||||
{
|
{
|
||||||
$this->connect_string .= "host=$sqlserver ";
|
$this->connect_string .= "host=$sqlserver ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if($database)
|
if($database)
|
||||||
{
|
{
|
||||||
$this->dbname = $database;
|
$this->dbname = $database;
|
||||||
|
@ -98,7 +100,7 @@ class sql_db
|
||||||
{
|
{
|
||||||
if($this->query_result)
|
if($this->query_result)
|
||||||
{
|
{
|
||||||
@pg_freeresult($this->query_result);
|
pg_freeresult($this->query_result);
|
||||||
}
|
}
|
||||||
$result = @pg_close($this->db_connect_id);
|
$result = @pg_close($this->db_connect_id);
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -119,6 +121,8 @@ class sql_db
|
||||||
unset($this->query_result);
|
unset($this->query_result);
|
||||||
if($query != "")
|
if($query != "")
|
||||||
{
|
{
|
||||||
|
$query = preg_replace("/LIMIT ([0-9]+),([ 0-9]+)/", "LIMIT \\2, \\1", $query);
|
||||||
|
|
||||||
$this->query_result = @pg_exec($this->db_connect_id, $query);
|
$this->query_result = @pg_exec($this->db_connect_id, $query);
|
||||||
if($this->query_result)
|
if($this->query_result)
|
||||||
{
|
{
|
||||||
|
@ -230,11 +234,10 @@ class sql_db
|
||||||
}
|
}
|
||||||
if($query_id)
|
if($query_id)
|
||||||
{
|
{
|
||||||
$this->row = @pg_fetch_array($query_id, $this->rownum[$query_id]);
|
$this->row = @pg_fetch_array($query_id, $this->rownum[$query_id], PGSQL_ASSOC);
|
||||||
if($this->row)
|
if($this->row)
|
||||||
{
|
{
|
||||||
$this->rownum[$query_id]++;
|
$this->rownum[$query_id]++;
|
||||||
}
|
|
||||||
return $this->row;
|
return $this->row;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -242,6 +245,11 @@ class sql_db
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
function sql_fetchrowset($query_id = 0)
|
function sql_fetchrowset($query_id = 0)
|
||||||
{
|
{
|
||||||
if(!$query_id)
|
if(!$query_id)
|
||||||
|
@ -254,7 +262,7 @@ class sql_db
|
||||||
unset($this->row[$query_id]);
|
unset($this->row[$query_id]);
|
||||||
$this->rownum[$query_id] = 0;
|
$this->rownum[$query_id] = 0;
|
||||||
|
|
||||||
while($this->rowset = @pg_fetch_array($query_id, $this->rownum[$query_id]))
|
while($this->rowset = @pg_fetch_array($query_id, $this->rownum[$query_id], PGSQL_ASSOC))
|
||||||
{
|
{
|
||||||
$result[] = $this->rowset;
|
$result[] = $this->rowset;
|
||||||
$this->rownum[$query_id]++;
|
$this->rownum[$query_id]++;
|
||||||
|
@ -276,17 +284,17 @@ class sql_db
|
||||||
{
|
{
|
||||||
if($row_offset != -1)
|
if($row_offset != -1)
|
||||||
{
|
{
|
||||||
$this->row = @pg_fetch_array($query_id, $row_offset);
|
$this->row = @pg_fetch_array($query_id, $row_offset, PGSQL_ASSOC);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if($this->rownum[$query_id])
|
if($this->rownum[$query_id])
|
||||||
{
|
{
|
||||||
$this->row = @pg_fetch_array($query_id, $this->rownum[$query_id]-1);
|
$this->row = @pg_fetch_array($query_id, $this->rownum[$query_id]-1, PGSQL_ASSOC);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->row = @pg_fetch_array($query_id, $this->rownum[$query_id]);
|
$this->row = @pg_fetch_array($query_id, $this->rownum[$query_id], PGSQL_ASSOC);
|
||||||
if($this->row)
|
if($this->row)
|
||||||
{
|
{
|
||||||
$this->rownum[$query_id]++;
|
$this->rownum[$query_id]++;
|
||||||
|
@ -332,12 +340,13 @@ class sql_db
|
||||||
{
|
{
|
||||||
if( eregi("^(INSERT{1}|^INSERT INTO{1})[[:space:]][\"]?([a-zA-Z0-9\_\-]+)[\"]?", $this->last_query_text[$query_id], $tablename))
|
if( eregi("^(INSERT{1}|^INSERT INTO{1})[[:space:]][\"]?([a-zA-Z0-9\_\-]+)[\"]?", $this->last_query_text[$query_id], $tablename))
|
||||||
{
|
{
|
||||||
$query = "SELECT last_value FROM ".$tablename[2]."_id_seq";
|
$query = "SELECT last_value
|
||||||
$temp_q_id = pg_exec($this->db_connect_id, $query);
|
FROM ".$tablename[2]."_id_seq";
|
||||||
$temp_result = pg_fetch_array($temp_q_id, 0);
|
$temp_q_id = @pg_exec($this->db_connect_id, $query);
|
||||||
|
$temp_result = @pg_fetch_array($temp_q_id, 0, PGSQL_ASSOC);
|
||||||
if($temp_result)
|
if($temp_result)
|
||||||
{
|
{
|
||||||
return $temp_result["last_value"]+1;
|
return $temp_result['last_value']+1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue