1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-08 08:35:31 +02:00

[ticket/10858] Move generic row seeking to DBAL

Removed from: firebird, mssql_odbc, and mssqlnative

PHPBB3-10858
This commit is contained in:
Patrick Webster 2012-05-08 19:41:22 -05:00
parent afbaa6979b
commit 09d49fb7b2
4 changed files with 43 additions and 129 deletions

View File

@ -194,6 +194,49 @@ class dbal
return false;
}
/**
* Seek to given row number
* rownum is zero-based
*/
function sql_rowseek($rownum, &$query_id)
{
global $cache;
if ($query_id === false)
{
$query_id = $this->query_result;
}
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_rowseek($rownum, $query_id);
}
if ($query_id === false)
{
return false;
}
$this->sql_freeresult($query_id);
$query_id = $this->sql_query($this->last_query_text);
if ($query_id === false)
{
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++)
{
if (!$this->sql_fetchrow($query_id))
{
return false;
}
}
return true;
}
/**
* Fetch field
* if rownum is false, the current row is used, else it is pointing to the row (zero-based)

View File

@ -359,49 +359,6 @@ class dbal_firebird extends dbal
return (sizeof($row)) ? $row : false;
}
/**
* Seek to given row number
* rownum is zero-based
*/
function sql_rowseek($rownum, &$query_id)
{
global $cache;
if ($query_id === false)
{
$query_id = $this->query_result;
}
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_rowseek($rownum, $query_id);
}
if ($query_id === false)
{
return;
}
$this->sql_freeresult($query_id);
$query_id = $this->sql_query($this->last_query_text);
if ($query_id === false)
{
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++)
{
if (!$this->sql_fetchrow($query_id))
{
return false;
}
}
return true;
}
/**
* Get last inserted id after insert statement
*/

View File

@ -255,49 +255,6 @@ class dbal_mssql_odbc extends dbal
return ($query_id !== false) ? @odbc_fetch_array($query_id) : false;
}
/**
* Seek to given row number
* rownum is zero-based
*/
function sql_rowseek($rownum, &$query_id)
{
global $cache;
if ($query_id === false)
{
$query_id = $this->query_result;
}
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_rowseek($rownum, $query_id);
}
if ($query_id === false)
{
return false;
}
$this->sql_freeresult($query_id);
$query_id = $this->sql_query($this->last_query_text);
if ($query_id === false)
{
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++)
{
if (!$this->sql_fetchrow($query_id))
{
return false;
}
}
return true;
}
/**
* Get last inserted id after insert statement
*/

View File

@ -439,49 +439,6 @@ class dbal_mssqlnative extends dbal
return $row;
}
/**
* Seek to given row number
* rownum is zero-based
*/
function sql_rowseek($rownum, &$query_id)
{
global $cache;
if ($query_id === false)
{
$query_id = $this->query_result;
}
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_rowseek($rownum, $query_id);
}
if ($query_id === false)
{
return false;
}
$this->sql_freeresult($query_id);
$query_id = $this->sql_query($this->last_query_text);
if ($query_id === false)
{
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++)
{
if (!$this->sql_fetchrow($query_id))
{
return false;
}
}
return true;
}
/**
* Get last inserted id after insert statement
*/