|
From: Paul S. O. <ps...@us...> - 2001-12-18 01:13:41
|
Update of /cvsroot/phpbb/phpBB2/db
In directory usw-pr-cvs1:/tmp/cvs-serv14394/db
Modified Files:
mssql-odbc.php msaccess.php
Log Message:
Updated classes, fixed slashing issue and maybe reduced overhead a little, perhaps
Index: mssql-odbc.php
===================================================================
RCS file: /cvsroot/phpbb/phpBB2/db/mssql-odbc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** mssql-odbc.php 2001/11/30 23:15:53 1.2
--- mssql-odbc.php 2001/12/18 01:13:37 1.3
***************
*** 29,38 ****
var $db_connect_id;
! var $query_result;
! var $query_resultset;
! var $query_numrows;
var $next_id;
! var $row;
! var $row_index;
var $num_queries = 0;
--- 29,42 ----
var $db_connect_id;
! var $result;
!
var $next_id;
!
! var $num_rows;
! var $current_row;
! var $field_names;
! var $field_types;
! var $result_rowset;
!
var $num_queries = 0;
***************
*** 43,69 ****
{
$this->persistency = $persistency;
$this->user = $sqluser;
$this->password = $sqlpassword;
$this->dbname = $database;
! $this->server = $sqlserver;
!
! if($this->persistency)
! {
! $this->db_connect_id = odbc_pconnect($this->server, $this->user, $this->password);
! }
! else
! {
! $this->db_connect_id = odbc_connect($this->server, $this->user, $this->password);
! }
! if($this->db_connect_id)
! {
! return $this->db_connect_id;
! }
! else
! {
! return false;
! }
}
//
--- 47,58 ----
{
$this->persistency = $persistency;
+ $this->server = $sqlserver;
$this->user = $sqluser;
$this->password = $sqlpassword;
$this->dbname = $database;
! $this->db_connect_id = ($this->persistency) ? odbc_pconnect($this->server, $this->user, $this->password) : odbc_connect($this->server, $this->user, $this->password);
! return ( $this->db_connect_id ) ? $this->db_connect_id : false;
}
//
***************
*** 74,83 ****
if($this->db_connect_id)
{
! if($this->query_result)
{
! @odbc_free_result($this->query_result);
}
! $result = @odbc_close($this->db_connect_id);
! return $result;
}
else
--- 63,81 ----
if($this->db_connect_id)
{
! if( $this->in_transaction )
{
! @odbc_commit($this->db_connect_id);
}
!
! if( count($this->result_rowset) )
! {
! unset($this->result_rowset);
! unset($this->field_names);
! unset($this->field_types);
! unset($this->num_rows);
! unset($this->current_row);
! }
!
! return @odbc_close($this->db_connect_id);
}
else
***************
*** 87,91 ****
}
-
//
// Query method
--- 85,88 ----
***************
*** 93,195 ****
function sql_query($query = "", $transaction = FALSE)
{
! //
! // Remove any pre-existing queries
! //
! unset($this->query_result);
! unset($this->row);
! if($query != "")
{
$this->num_queries++;
! if(!eregi("^INSERT ",$query))
{
! if(eregi("LIMIT", $query))
{
! preg_match("/^(.*)LIMIT ([0-9]+)[, ]*([0-9]+)*/s", $query, $limits);
!
! $query = $limits[1];
! if($limits[3])
! {
! $row_offset = $limits[2];
! $num_rows = $limits[3];
! }
! else
! {
! $row_offset = 0;
! $num_rows = $limits[2];
! }
! $this->query_result = odbc_exec($this->db_connect_id, $query);
! $query_limit_offset = $row_offset;
! $this->result_numrows[$this->query_result] = $num_rows;
! }
! else
{
! $this->query_result = odbc_exec($this->db_connect_id, $query);
! $row_offset = 0;
! $this->result_numrows[$this->query_result] = 5E6;
}
! $result_id = $this->query_result;
! if($this->query_result && eregi("^SELECT", $query))
! {
! for($i = 1; $i < odbc_num_fields($result_id)+1; $i++)
{
! $this->result_field_names[$result_id][] = odbc_field_name($result_id, $i);
}
! $i = $row_offset + 1;
! $k = 0;
! while(odbc_fetch_row($result_id, $i) && $k < $this->result_numrows[$result_id])
! {
! for($j = 1; $j < count($this->result_field_names[$result_id])+1; $j++)
{
! $this->result_rowset[$result_id][$k][$this->result_field_names[$result_id][$j-1]] = odbc_result($result_id, $j);
}
! $i++;
! $k++;
}
! $this->result_numrows[$result_id] = $k;
! $this->row_index[$result_id] = 0;
}
! else
{
! $this->result_numrows[$result_id] = @odbc_num_rows($result_id);
! $this->row_index[$result_id] = 0;
}
}
else
{
! if(eregi("^(INSERT|UPDATE) ", $query))
{
! $query = preg_replace("/\\\'/s", "''", $query);
}
! $this->query_result = odbc_exec($this->db_connect_id, $query);
! if($this->query_result)
{
! $sql_id = "SELECT @@IDENTITY";
!
! $id_result = odbc_exec($this->db_connect_id, $sql_id);
! if($id_result)
! {
! $row_result = odbc_fetch_row($id_result);
! if($row_result)
! {
! $this->next_id[$this->query_result] = odbc_result($id_result, 1);
! }
! }
}
! $this->query_limit_offset[$this->query_result] = 0;
! $this->result_numrows[$this->query_result] = 0;
}
! return $this->query_result;
}
else
--- 90,202 ----
function sql_query($query = "", $transaction = FALSE)
{
! if( $query != "" )
{
$this->num_queries++;
! if( $transaction == BEGIN_TRANSACTION )
{
! if( !odbc_autocommit($this->db_connect_id, false) )
{
! return false;
! }
! $this->in_transaction = TRUE;
! }
! if( preg_match("/^SELECT(.*?)(LIMIT ([0-9]+)[, ]*([0-9]+)*)?$/s", $query, $limits) )
! {
! $query = $limits[1];
! if( !empty($limits[2]) )
{
! $row_offset = ( $limits[4] ) ? $limits[3] : "";
! $num_rows = ( $limits[4] ) ? $limits[4] : $limits[3];
! $query = "TOP " . ( $row_offset + $num_rows ) . $query;
}
! $this->result = odbc_exec($this->db_connect_id, "SELECT $query");
! if( $this->result )
! {
! if( empty($this->field_names[$this->result]) )
{
! for($i = 1; $i < odbc_num_fields($this->result) + 1; $i++)
! {
! $this->field_names[$this->result][] = odbc_field_name($this->result, $i);
! $this->field_types[$this->result][] = odbc_field_type($this->result, $i);
! }
}
! $this->current_row[$this->result] = 0;
! $this->result_rowset[$this->result] = array();
!
! $row_outer = ( isset($row_offset) ) ? $row_offset + 1 : 1;
! $row_outer_max = ( isset($num_rows) ) ? $num_rows + 1 : 1E9;
! $row_inner = 0;
! while( odbc_fetch_row($this->result, $row_outer) && $row_outer < $row_outer_max )
! {
! for($j = 0; $j < count($this->field_names[$this->result]); $j++)
{
! $this->result_rowset[$this->result][$row_inner][$this->field_names[$this->result][$j]] = stripslashes(odbc_result($this->result, $j + 1));
}
!
! $row_outer++;
! $row_inner++;
}
! $this->num_rows[$this->result] = count($this->result_rowset[$this->result]);
}
!
! }
! else if( eregi("^INSERT ", $query) )
! {
! $this->result = odbc_exec($this->db_connect_id, str_replace("\'", "''", $query));
!
! if( $this->result )
{
! $result_id = odbc_exec($this->db_connect_id, "SELECT @@IDENTITY");
! if( $result_id )
! {
! if( odbc_fetch_row($result_id) )
! {
! $this->next_id[$this->db_connect_id] = odbc_result($result_id, 1);
! $this->affected_rows[$this->db_connect_id] = odbc_num_rows($this->result);
! }
! }
}
}
else
{
! $this->result = odbc_exec($this->db_connect_id, str_replace("\'", "''", $query));
!
! if( $this->result )
{
! $this->affected_rows[$this->db_connect_id] = odbc_num_rows($this->result);
}
! }
! if( !$this->result )
! {
! if( $this->in_transaction )
{
! odbc_rollback($this->db_connect_id);
! odbc_autocommit($this->db_connect_id, true);
! $this->in_transaction = FALSE;
}
! return false;
}
! if( $transaction == END_TRANSACTION && $this->in_transaction )
! {
! odbc_commit($this->db_connect_id);
! odbc_autocommit($this->db_connect_id, true);
! $this->in_transaction = FALSE;
! }
!
! odbc_free_result($this->result);
!
! return $this->result;
}
else
***************
*** 203,301 ****
//
function sql_numrows($query_id = 0)
- {
- if(!$query_id)
- {
- $query_id = $this->query_result;
- }
- if($query_id)
- {
- return $this->result_numrows[$query_id];
- }
- else
- {
- return false;
- }
- }
- function sql_affectedrows($query_id = 0)
{
! if(!$query_id)
{
! $query_id = $this->query_result;
}
! if($query_id)
! {
! return $this->result_numrows[$query_id];
! }
! else
! {
! return false;
! }
}
function sql_numfields($query_id = 0)
{
! if(!$query_id)
! {
! $query_id = $this->query_result;
! }
! if($query_id)
{
! $result = count($this->result_field_names[$query_id]);
! return $result;
! }
! else
! {
! return false;
}
}
function sql_fieldname($offset, $query_id = 0)
{
! if(!$query_id)
! {
! $query_id = $this->query_result;
! }
! if($query_id)
{
! $result = $this->result_field_names[$query_id][$offset];
! return $result;
}
! else
! {
! return false;
! }
}
function sql_fieldtype($offset, $query_id = 0)
{
! if(!$query_id)
! {
! $query_id = $this->query_result;
! }
! if($query_id)
! {
! $result = @odbc_field_type($query_id, $offset);
! return $result;
! }
! else
{
! return false;
}
}
function sql_fetchrow($query_id = 0)
{
! if(!$query_id)
{
! $query_id = $this->query_result;
}
! if($query_id)
{
! if($this->row_index[$query_id] < $this->result_numrows[$query_id])
! {
! $result = $this->result_rowset[$query_id][$this->row_index[$query_id]];
! $this->row_index[$query_id]++;
! return $result;
! }
! else
! {
! return false;
! }
}
else
--- 210,262 ----
//
function sql_numrows($query_id = 0)
{
! if( !$query_id )
{
! $query_id = $this->result;
}
!
! return ( $query_id ) ? $this->num_rows[$query_id] : false;
}
+
function sql_numfields($query_id = 0)
{
! if( !$query_id )
{
! $query_id = $this->result;
}
+
+ return ( $query_id ) ? count($this->field_names[$query_id]) : false;
}
+
function sql_fieldname($offset, $query_id = 0)
{
! if( !$query_id )
{
! $query_id = $this->result;
}
!
! return ( $query_id ) ? $this->field_names[$query_id][$offset] : false;
}
+
function sql_fieldtype($offset, $query_id = 0)
{
! if( !$query_id )
{
! $query_id = $this->result;
}
+
+ return ( $query_id ) ? $this->field_types[$query_id][$offset] : false;
}
+
function sql_fetchrow($query_id = 0)
{
! if( !$query_id )
{
! $query_id = $this->result;
}
!
! if( $query_id )
{
! return ( $this->num_rows[$query_id] && $this->current_row[$query_id] < $this->num_rows[$query_id] ) ? $this->result_rowset[$query_id][$this->current_row[$query_id]++] : false;
}
else
***************
*** 304,317 ****
}
}
function sql_fetchrowset($query_id = 0)
{
! if(!$query_id)
{
! $query_id = $this->query_result;
}
! if($query_id)
{
! $this->row_index[$query_id] = $this->result_numrows[$query_id];
! return $this->result_rowset[$query_id];
}
else
--- 265,279 ----
}
}
+
function sql_fetchrowset($query_id = 0)
{
! if( !$query_id )
{
! $query_id = $this->result;
}
!
! if( $query_id )
{
! return ( $this->num_rows[$query_id] ) ? $this->result_rowset[$query_id] : false;
}
else
***************
*** 320,343 ****
}
}
function sql_fetchfield($field, $row = -1, $query_id = 0)
{
! if(!$query_id)
{
! $query_id = $this->query_result;
}
! if($query_id)
{
! if($row < $this->result_numrows[$query_id])
{
! if($row == -1)
! {
! $getrow = $this->row_index[$query_id]-1;
! }
! else
! {
! $getrow = $row;
! }
! return $this->result_rowset[$query_id][$getrow][$this->result_field_names[$query_id][$field]];
}
--- 282,300 ----
}
}
+
function sql_fetchfield($field, $row = -1, $query_id = 0)
{
! if( !$query_id )
{
! $query_id = $this->result;
}
!
! if( $query_id )
{
! if( $row < $this->num_rows[$query_id] )
{
! $getrow = ( $row == -1 ) ? $this->current_row[$query_id] - 1 : $row;
! return $this->result_rowset[$query_id][$getrow][$this->field_names[$query_id][$field]];
}
***************
*** 352,364 ****
}
}
function sql_rowseek($offset, $query_id = 0)
{
! if(!$query_id)
{
! $query_id = $this->query_result;
}
! if($query_id)
{
! $this->row_index[$query_id] = 0;
return true;
}
--- 309,323 ----
}
}
+
function sql_rowseek($offset, $query_id = 0)
{
! if( !$query_id )
{
! $query_id = $this->result;
}
!
! if( $query_id )
{
! $this->current_row[$query_id] = $offset - 1;
return true;
}
***************
*** 368,408 ****
}
}
! function sql_nextid($query_id = 0)
{
! if(!$query_id)
! {
! $query_id = $this->query_result;
! }
! if($query_id)
! {
! return $this->next_id[$query_id];
! }
! else
! {
! return false;
! }
}
function sql_freeresult($query_id = 0)
{
! if(!$query_id)
{
! $query_id = $this->query_result;
}
! if($query_id)
! {
! $result = @odbc_free_result($query_id);
! return $result;
! }
! else
! {
! return false;
! }
}
! function sql_error($query_id = 0)
{
! // $result['code'] = @odbc_error($this->db_connect_id);
! // $result['message'] = @odbc_errormsg($this->db_connect_id);
! return "";
}
--- 327,363 ----
}
}
!
! function sql_nextid()
{
! return ( $this->next_id[$this->db_connect_id] ) ? $this->next_id[$this->db_connect_id] : false;
}
+
+ function sql_affectedrows()
+ {
+ return ( $this->affected_rows[$this->db_connect_id] ) ? $this->affected_rows[$this->db_connect_id] : false;
+ }
+
function sql_freeresult($query_id = 0)
{
! if( !$query_id )
{
! $query_id = $this->result;
}
!
! unset($this->num_rows[$query_id]);
! unset($this->current_row[$query_id]);
! unset($this->result_rowset[$query_id]);
! unset($this->field_names[$query_id]);
! unset($this->field_types[$query_id]);
!
! return true;
}
!
! function sql_error()
{
! $error['code'] = odbc_error($this->db_connect_id);
! $error['message'] = odbc_errormsg($this->db_connect_id);
! return $error;
}
Index: msaccess.php
===================================================================
RCS file: /cvsroot/phpbb/phpBB2/db/msaccess.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** msaccess.php 2001/11/20 22:27:29 1.1
--- msaccess.php 2001/12/18 01:13:37 1.2
***************
*** 29,38 ****
var $db_connect_id;
! var $query_result;
! var $query_resultset;
! var $query_numrows;
var $next_id;
! var $row;
! var $row_index;
var $num_queries = 0;
--- 29,43 ----
var $db_connect_id;
! var $result_ids;
! var $result;
!
var $next_id;
!
! var $num_rows;
! var $current_row;
! var $field_names;
! var $field_types;
! var $result_rowset;
!
var $num_queries = 0;
***************
*** 40,68 ****
// Constructor
//
! function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = false)
{
$this->persistency = $persistency;
$this->user = $sqluser;
$this->password = $sqlpassword;
$this->dbname = $database;
- $this->server = $sqlserver;
! if($this->persistency)
! {
! $this->db_connect_id = odbc_pconnect($this->server, "", "");
! }
! else
! {
! $this->db_connect_id = odbc_connect($this->server, "", "");
! }
! if($this->db_connect_id)
! {
! return $this->db_connect_id;
! }
! else
! {
! return false;
! }
}
//
--- 45,59 ----
// Constructor
//
! function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
{
$this->persistency = $persistency;
+ $this->server = $sqlserver;
$this->user = $sqluser;
$this->password = $sqlpassword;
$this->dbname = $database;
! $this->db_connect_id = ($this->persistency) ? odbc_pconnect($this->server, $this->user, $this->password) : odbc_connect($this->server, $this->user, $this->password);
! return ( $this->db_connect_id ) ? $this->db_connect_id : false;
}
//
***************
*** 73,82 ****
if($this->db_connect_id)
{
! if($this->query_result)
{
! @odbc_free_result($this->query_result);
}
! $result = @odbc_close($this->db_connect_id);
! return $result;
}
else
--- 64,82 ----
if($this->db_connect_id)
{
! if( $this->in_transaction )
! {
! @odbc_commit($this->db_connect_id);
! }
!
! if( count($this->result_rowset) )
{
! unset($this->result_rowset);
! unset($this->field_names);
! unset($this->field_types);
! unset($this->num_rows);
! unset($this->current_row);
}
!
! return @odbc_close($this->db_connect_id);
}
else
***************
*** 86,90 ****
}
-
//
// Query method
--- 86,89 ----
***************
*** 92,197 ****
function sql_query($query = "", $transaction = FALSE)
{
! //
! // Remove any pre-existing queries
! //
! unset($this->query_result);
! unset($this->row);
! if($query != "")
{
$this->num_queries++;
-
- $query = str_replace("LOWER(", "LCASE(", $query);
! if(!eregi("^INSERT ",$query))
{
! if(eregi("LIMIT", $query))
{
! preg_match("/^(.*)LIMIT ([0-9]+)[, ]*([0-9]+)*/s", $query, $limits);
!
! $query = $limits[1];
! if($limits[3])
! {
! $row_offset = $limits[2];
! $num_rows = $limits[3];
! }
! else
! {
! $row_offset = 0;
! $num_rows = $limits[2];
! }
! $this->query_result = odbc_exec($this->db_connect_id, $query);
! $query_limit_offset = $row_offset;
! $this->result_numrows[$this->query_result] = $num_rows;
! }
! else
{
! $this->query_result = odbc_exec($this->db_connect_id, $query);
! $row_offset = 0;
! $this->result_numrows[$this->query_result] = 5E6;
}
! $result_id = $this->query_result;
! if($this->query_result && eregi("^SELECT", $query))
! {
! for($i = 1; $i < odbc_num_fields($result_id)+1; $i++)
{
! $this->result_field_names[$result_id][] = odbc_field_name($result_id, $i);
}
! $i = $row_offset + 1;
! $k = 0;
! while(odbc_fetch_row($result_id, $i) && $k < $this->result_numrows[$result_id])
! {
! for($j = 1; $j < count($this->result_field_names[$result_id])+1; $j++)
{
! $this->result_rowset[$result_id][$k][$this->result_field_names[$result_id][$j-1]] = odbc_result($result_id, $j);
}
! $i++;
! $k++;
}
! $this->result_numrows[$result_id] = $k;
! $this->row_index[$result_id] = 0;
}
! else
{
! $this->result_numrows[$result_id] = @odbc_num_rows($result_id);
! $this->row_index[$result_id] = 0;
}
}
else
{
! if(eregi("^(INSERT|UPDATE) ", $query))
{
! $query = preg_replace("/\\\'/s", "''", $query);
}
!
! $this->query_result = odbc_exec($this->db_connect_id, $query);
! if($this->query_result)
{
! $sql_id = "SELECT @@IDENTITY";
!
! $id_result = odbc_exec($this->db_connect_id, $sql_id);
! if($id_result)
! {
! $row_result = odbc_fetch_row($id_result);
! if($row_result)
! {
! $this->next_id[$this->query_result] = odbc_result($id_result, 1);
! }
! }
}
! $this->query_limit_offset[$this->query_result] = 0;
! $this->result_numrows[$this->query_result] = 0;
}
! return $this->query_result;
}
else
--- 91,203 ----
function sql_query($query = "", $transaction = FALSE)
{
! if( $query != "" )
{
$this->num_queries++;
! if( $transaction == BEGIN_TRANSACTION )
{
! if( !odbc_autocommit($this->db_connect_id, false) )
{
! return false;
! }
! $this->in_transaction = TRUE;
! }
! if( preg_match("/^SELECT(.*?)(LIMIT ([0-9]+)[, ]*([0-9]+)*)?$/s", $query, $limits) )
! {
! $query = $limits[1];
! if( !empty($limits[2]) )
{
! $row_offset = ( $limits[4] ) ? $limits[3] : "";
! $num_rows = ( $limits[4] ) ? $limits[4] : $limits[3];
! $query = "TOP " . ( $row_offset + $num_rows ) . $query;
}
! $this->result = odbc_exec($this->db_connect_id, "SELECT $query");
! if( $this->result )
! {
! if( empty($this->field_names[$this->result]) )
{
! for($i = 1; $i < odbc_num_fields($this->result) + 1; $i++)
! {
! $this->field_names[$this->result][] = odbc_field_name($this->result, $i);
! $this->field_types[$this->result][] = odbc_field_type($this->result, $i);
! }
}
! $this->current_row[$this->result] = 0;
! $this->result_rowset[$this->result] = array();
!
! $row_outer = ( isset($row_offset) ) ? $row_offset + 1 : 1;
! $row_outer_max = ( isset($num_rows) ) ? $num_rows + 1 : 1E9;
! $row_inner = 0;
! while( odbc_fetch_row($this->result, $row_outer) && $row_outer < $row_outer_max )
! {
! for($j = 0; $j < count($this->field_names[$this->result]); $j++)
{
! $this->result_rowset[$this->result][$row_inner][$this->field_names[$this->result][$j]] = stripslashes(odbc_result($this->result, $j + 1));
}
!
! $row_outer++;
! $row_inner++;
}
+
+ $this->num_rows[$this->result] = count($this->result_rowset[$this->result]);
! odbc_free_result($this->result);
}
!
! }
! else if( eregi("^INSERT ", $query) )
! {
! $this->result = odbc_exec($this->db_connect_id, str_replace("\'", "''", $query));
!
! if( $this->result )
{
! $result_id = odbc_exec($this->db_connect_id, "SELECT @@IDENTITY");
! if( $result_id )
! {
! if( odbc_fetch_row($result_id) )
! {
! $this->next_id[$this->db_connect_id] = odbc_result($result_id, 1);
! $this->affected_rows[$this->db_connect_id] = odbc_num_rows($this->result);
! }
! }
}
}
else
{
! $this->result = odbc_exec($this->db_connect_id, str_replace("\'", "''", $query));
!
! if( $this->result )
{
! $this->affected_rows[$this->db_connect_id] = odbc_num_rows($this->result);
}
! }
! if( !$this->result )
! {
! if( $this->in_transaction )
{
! odbc_rollback($this->db_connect_id);
! odbc_autocommit($this->db_connect_id, true);
! $this->in_transaction = FALSE;
}
! return false;
}
! if( $transaction == END_TRANSACTION && $this->in_transaction )
! {
! odbc_commit($this->db_connect_id);
! odbc_autocommit($this->db_connect_id, true);
! $this->in_transaction = FALSE;
! }
!
! return $this->result;
}
else
***************
*** 205,303 ****
//
function sql_numrows($query_id = 0)
- {
- if(!$query_id)
- {
- $query_id = $this->query_result;
- }
- if($query_id)
- {
- return $this->result_numrows[$query_id];
- }
- else
- {
- return false;
- }
- }
- function sql_affectedrows($query_id = 0)
{
! if(!$query_id)
{
! $query_id = $this->query_result;
}
! if($query_id)
! {
! return $this->result_numrows[$query_id];
! }
! else
! {
! return false;
! }
}
function sql_numfields($query_id = 0)
{
! if(!$query_id)
! {
! $query_id = $this->query_result;
! }
! if($query_id)
{
! $result = count($this->result_field_names[$query_id]);
! return $result;
! }
! else
! {
! return false;
}
}
function sql_fieldname($offset, $query_id = 0)
{
! if(!$query_id)
! {
! $query_id = $this->query_result;
! }
! if($query_id)
{
! $result = $this->result_field_names[$query_id][$offset];
! return $result;
}
! else
! {
! return false;
! }
}
function sql_fieldtype($offset, $query_id = 0)
{
! if(!$query_id)
! {
! $query_id = $this->query_result;
! }
! if($query_id)
! {
! $result = @odbc_field_type($query_id, $offset);
! return $result;
! }
! else
{
! return false;
}
}
function sql_fetchrow($query_id = 0)
{
! if(!$query_id)
{
! $query_id = $this->query_result;
}
! if($query_id)
{
! if($this->row_index[$query_id] < $this->result_numrows[$query_id])
! {
! $result = $this->result_rowset[$query_id][$this->row_index[$query_id]];
! $this->row_index[$query_id]++;
! return $result;
! }
! else
! {
! return false;
! }
}
else
--- 211,263 ----
//
function sql_numrows($query_id = 0)
{
! if( !$query_id )
{
! $query_id = $this->result;
}
!
! return ( $query_id ) ? $this->num_rows[$query_id] : false;
}
+
function sql_numfields($query_id = 0)
{
! if( !$query_id )
{
! $query_id = $this->result;
}
+
+ return ( $query_id ) ? count($this->field_names[$query_id]) : false;
}
+
function sql_fieldname($offset, $query_id = 0)
{
! if( !$query_id )
{
! $query_id = $this->result;
}
!
! return ( $query_id ) ? $this->field_names[$query_id][$offset] : false;
}
+
function sql_fieldtype($offset, $query_id = 0)
{
! if( !$query_id )
{
! $query_id = $this->result;
}
+
+ return ( $query_id ) ? $this->field_types[$query_id][$offset] : false;
}
+
function sql_fetchrow($query_id = 0)
{
! if( !$query_id )
{
! $query_id = $this->result;
}
!
! if( $query_id )
{
! return ( $this->num_rows[$query_id] && $this->current_row[$query_id] < $this->num_rows[$query_id] ) ? $this->result_rowset[$query_id][$this->current_row[$query_id]++] : false;
}
else
***************
*** 306,319 ****
}
}
function sql_fetchrowset($query_id = 0)
{
! if(!$query_id)
{
! $query_id = $this->query_result;
}
! if($query_id)
{
! $this->row_index[$query_id] = $this->result_numrows[$query_id];
! return $this->result_rowset[$query_id];
}
else
--- 266,280 ----
}
}
+
function sql_fetchrowset($query_id = 0)
{
! if( !$query_id )
{
! $query_id = $this->result;
}
!
! if( $query_id )
{
! return ( $this->num_rows[$query_id] ) ? $this->result_rowset[$query_id] : false;
}
else
***************
*** 322,346 ****
}
}
function sql_fetchfield($field, $row = -1, $query_id = 0)
{
! if(!$query_id)
{
! $query_id = $this->query_result;
}
! if($query_id)
{
! if($row < $this->result_numrows[$query_id])
{
! if($row == -1)
! {
! $getrow = $this->row_index[$query_id]-1;
! }
! else
! {
! $getrow = $row;
! }
!
! return $this->result_rowset[$query_id][$getrow][$this->result_field_names[$query_id][$field]];
}
else
--- 283,301 ----
}
}
+
function sql_fetchfield($field, $row = -1, $query_id = 0)
{
! if( !$query_id )
{
! $query_id = $this->result;
}
!
! if( $query_id )
{
! if( $row < $this->num_rows[$query_id] )
{
! $getrow = ($row == -1) ? $this->current_row[$query_id] - 1 : $row;
+ return $this->result_rowset[$query_id][$getrow][$this->field_names[$query_id][$field]];
}
else
***************
*** 354,366 ****
}
}
function sql_rowseek($offset, $query_id = 0)
{
! if(!$query_id)
{
! $query_id = $this->query_result;
}
! if($query_id)
{
! $this->row_index[$query_id] = 0;
return true;
}
--- 309,323 ----
}
}
+
function sql_rowseek($offset, $query_id = 0)
{
! if( !$query_id )
{
! $query_id = $this->result;
}
!
! if( $query_id )
{
! $this->current_row[$query_id] = $offset - 1;
return true;
}
***************
*** 370,410 ****
}
}
! function sql_nextid($query_id = 0)
{
! if(!$query_id)
! {
! $query_id = $this->query_result;
! }
! if($query_id)
! {
! return $this->next_id[$query_id];
! }
! else
! {
! return false;
! }
}
function sql_freeresult($query_id = 0)
{
! if(!$query_id)
{
! $query_id = $this->query_result;
}
! if($query_id)
! {
! $result = @odbc_free_result($query_id);
! return $result;
! }
! else
! {
! return false;
! }
}
function sql_error($query_id = 0)
{
! // $result['code'] = @odbc_error($this->db_connect_id);
! // $result['message'] = @odbc_errormsg($this->db_connect_id);
! return "";
}
--- 327,363 ----
}
}
!
! function sql_nextid()
{
! return ( $this->next_id[$this->db_connect_id] ) ? $this->next_id[$this->db_connect_id] : false;
}
+
+ function sql_affectedrows()
+ {
+ return ( $this->affected_rows[$this->db_connect_id] ) ? $this->affected_rows[$this->db_connect_id] : false;
+ }
+
function sql_freeresult($query_id = 0)
{
! if( !$query_id )
{
! $query_id = $this->result;
}
!
! unset($this->num_rows[$query_id]);
! unset($this->current_row[$query_id]);
! unset($this->result_rowset[$query_id]);
! unset($this->field_names[$query_id]);
! unset($this->field_types[$query_id]);
!
! return true;
}
+
function sql_error($query_id = 0)
{
! $error['code'] = odbc_error($this->db_connect_id);
! $error['message'] = odbc_errormsg($this->db_connect_id);
! return $error;
}
|