cvs: php4 /pear/DB odbc.php pgsql.php

From: Date: Thu, 22 Jun 2000 12:57:57 +0000
Subject: cvs: php4 /pear/DB odbc.php pgsql.php
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-391@lists.php.net to get a copy of this message
hirokawa Thu Jun 22 05:57:57 2000 EDT Modified files: /php4/pear/DB odbc.php pgsql.php Log: added a variable to save the current row in pgsql. added a function to odbc module. Index: php4/pear/DB/odbc.php diff -u php4/pear/DB/odbc.php:1.7 php4/pear/DB/odbc.php:1.8 --- php4/pear/DB/odbc.php:1.7 Tue Jun 20 19:22:04 2000 +++ php4/pear/DB/odbc.php Thu Jun 22 05:57:57 2000 @@ -161,9 +161,36 @@ } // Determine which queries that should return data, and which // should return an error code only. - if (eregi('SELECT', $query)) { + if (preg_match('/SELECT/i', $query)) { $resultObj = new DB_result($this, $result); return $resultObj; // XXX ADDREF + } else { + return DB_OK; + } + } + + // }}} + // {{{ simpleQuery() + + /** + * Send a query to ODBC and return the results as a ODBC resource + * identifier. + * + * @param $query the SQL query + * + * @return int returns a valid ODBC result for successful SELECT + * queries, DB_OK for other successful queries. A DB error code + * is returned on failure. + */ + function simpleQuery($query) { + $result = odbc_exec($this->connection, $query); + if (!$result) { + return DB_ERROR; // XXX ERRORMSG + } + // Determine which queries that should return data, and which + // should return an error code only. + if (preg_match('/SELECT/i', $query)) { + return $result; } else { return DB_OK; } Index: php4/pear/DB/pgsql.php diff -u php4/pear/DB/pgsql.php:1.6 php4/pear/DB/pgsql.php:1.7 --- php4/pear/DB/pgsql.php:1.6 Tue Jun 20 19:22:05 2000 +++ php4/pear/DB/pgsql.php Thu Jun 22 05:57:57 2000 @@ -55,6 +55,7 @@ var $phptype, $dbsyntax; var $prepare_tokens = array(); var $prepare_types = array(); + var $numrows; var $row; // }}} @@ -70,6 +71,7 @@ 'transactions' => true ); $this->errorcode_map = array(); + $this->numrows = array(); $this->row = array(); } @@ -150,12 +152,12 @@ if (!$result) { return pg_errormessage($this->connection); } - $this->row[$result] = 0; // reset the row counter. - // Determine which queries that should return data, and which // should return an error code only. if (preg_match('/(SELECT|SHOW)/i', $query)) { $resultObj = new DB_result($this, $result); + $this->row[$result] = 0; // reset the row counter. + $this->numrows[$result] = pg_numrows($result); return $resultObj; } else { return DB_OK; @@ -180,11 +182,11 @@ if (!$result) { return pg_errormessage($this->connection); } - $this->row[$result] = 0; // reset the row counter. - // Determine which queries that should return data, and which // should return an error code only. if (preg_match('/(SELECT|SHOW)/i', $query)) { + $this->row[$result] = 0; // reset the row counter. + $this->numrows[$result] = pg_numrows($result); return $result; } else { return DB_OK; @@ -204,6 +206,9 @@ * if there is no more data */ function &fetchRow($result, $getmode = DB_GETMODE_DEFAULT) { + if ($this->row[$result]>=$this->numrows[$result]){ + return NULL; + } if ($getmode & DB_GETMODE_ASSOC) { $row = pg_fetch_array($result, $this->row[$result]); } else { @@ -233,6 +238,9 @@ * @return int DB_OK on success, a DB error code on failure */ function fetchInto($result, &$arr, $getmode = DB_GETMODE_DEFAULT) { + if ($this->row[$result]>=$this->numrows[$result]){ + return NULL; + } if ($getmode & DB_GETMODE_ASSOC) { $arr = pg_fetch_array($result, $this->row[$result]); } else { @@ -273,6 +281,7 @@ unset($this->prepare_tokens[$result]); unset($this->prepare_types[$result]); unset($this->row[$result]); + unset($this->numrows[$result]); return true; } @@ -370,6 +379,8 @@ return pg_errormessage($this->connection); } if (preg_match('/(SELECT|SHOW)/i', $realquery)) { + $this->row[$result] = 0; // reset the row counter. + $this->numrows[$result] = pg_numrows($result); return $result; } else { return DB_OK;

« previous php.cvs (#391) next »