cvs: php4 /pear/DB ifx.php msql.php
| From: | Thomas V.V.Cox | Date: | Sun, 22 Apr 2001 17:09:58 +0000 |
| Subject: | cvs: php4 /pear/DB ifx.php msql.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-72@lists.php.net to get a copy of this message | ||
cox Sun Apr 22 10:09:58 2001 EDT
Modified files:
/php4/pear/DB ifx.php msql.php
Log:
* msql.php
- Added fetch row numbers
- Fix fetchInto
- Some other updates
* ifx.php
small clean up
Index: php4/pear/DB/ifx.php
diff -u php4/pear/DB/ifx.php:1.5 php4/pear/DB/ifx.php:1.6
--- php4/pear/DB/ifx.php:1.5 Wed Mar 28 15:52:21 2001
+++ php4/pear/DB/ifx.php Sun Apr 22 10:09:57 2001
@@ -77,7 +77,7 @@
$connect_function = $persistent ? 'ifx_pconnect' : 'ifx_connect';
$this->connection = @$connect_function($dbname, $user, $pw);
if ($this->connection == false) {
- return $this->ifxraiseError(DB_ERROR_CONNECT_FAILED);
+ return $this->raiseError(DB_ERROR_CONNECT_FAILED);
}
return DB_OK;
}
@@ -119,9 +119,8 @@
// should return an error code only.
if (preg_match('/(SELECT)/i', $query)) {
return $result;
- } else {
- return DB_OK;
}
+ return DB_OK;
}
/**
@@ -168,8 +167,8 @@
*/
function fetchInto($result, &$row, $fetchmode, $rownum=null)
{
- if (($rownum !== null) && ($rownum <= 0)) {
- return $this->raiseError();
+ if (($rownum !== null) && ($rownum < 0)) {
+ return null;
}
// if $rownum is null, fetch row will return the next row
if (!$row = @ifx_fetch_row($result, $rownum)) {
Index: php4/pear/DB/msql.php
diff -u php4/pear/DB/msql.php:1.16 php4/pear/DB/msql.php:1.17
--- php4/pear/DB/msql.php:1.16 Mon Feb 19 04:22:26 2001
+++ php4/pear/DB/msql.php Sun Apr 22 10:09:57 2001
@@ -16,7 +16,7 @@
// | Authors: Sterling Hughes <sterling@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: msql.php,v 1.16 2001/02/19 12:22:26 ssb Exp $
+// $Id: msql.php,v 1.17 2001/04/22 17:09:57 cox Exp $
//
// Database independent query interface definition for PHP's Mini-SQL
// extension.
@@ -43,16 +43,8 @@
);
}
- function connect($dsn, $persistent = false)
+ function connect($dsninfo, $persistent = false)
{
- if(is_array($dsn)) {
- $dsninfo = &$dsn;
- } else {
- $dsninfo = DB::parseDSN($dsn);
- }
- if (!$dsninfo || !$dsninfo['phptype']) {
- return $this->raiseError();
- }
$this->dsn = $dsninfo;
$user = $dsninfo['username'];
$pw = $dsninfo['password'];
@@ -65,11 +57,12 @@
} else {
$conn = $connect_function($dbhost);
}
- if ($dsninfo['database']) {
- @msql_select_db($dsninfo['database'], $conn);
- } else {
- return $this->raiseError();
+ if (!$conn) {
+ $this->raiseError(DB_ERROR_CONNECT_FAILED);
}
+ if (!@msql_select_db($dsninfo['database'], $conn)){
+ return $this->raiseError(DB_ERROR_NODBSELECTED);
+ }
$this->connection = $conn;
return DB_OK;
}
@@ -81,7 +74,7 @@
function simpleQuery($query)
{
- $this->last_query = $query;
+ $this->last_query = $query;
$query = $this->modifyQuery($query);
$result = @msql_query($query, $this->connection);
if (!$result) {
@@ -92,39 +85,36 @@
return DB::isManip($query) ? DB_OK : $result;
}
- function &fetchRow($result, $fetchmode=DB_FETCHMODE_DEFAULT)
+ function fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null)
{
- if ($fetchmode == DB_FETCHMODE_DEFAULT) {
- $fetchmode = $this->fetchmode;
- }
- if ($fetchmode & DB_FETCHMODE_ASSOC) {
- $row = @msql_fetch_array($result, MSQL_ASSOC);
- } else {
- $row = @msql_fetch_row($result);
+ if ($fetchmode == DB_FETCHMODE_DEFAULT) {
+ $fetchmode = $this->fetchmode;
}
- if (!$row) {
- if ($error = msql_error()) {
- return $this->raiseError($error);
- } else {
- return null;
- }
+ $res = $this->fetchInto ($result, $arr, $fetchmode, $rownum);
+ if ($res !== DB_OK) {
+ return $res;
}
-
- return $row;
+ return $arr;
}
- function fetchInto($result, &$ar, $fetchmode=DB_FETCHMODE_DEFAULT)
+ function fetchInto($result, &$ar, $fetchmode, $rownum=null)
{
- if ($fetchmode == DB_FETCHMODE_DEFAULT) {
- $fetchmode = $this->fetchmode;
- }
+ if ($rownum !== null) {
+ if (!@msql_data_seek($result, $rownum)) {
+ return null;
+ }
+ }
if ($fetchmode & DB_FETCHMODE_ASSOC) {
$ar = @msql_fetch_array($result, MSQL_ASSOC);
} else {
$ar = @msql_fetch_row($result);
}
if (!$ar) {
- return $this->raiseError();
+ if ($error = msql_error()) {
+ return $this->raiseError($error);
+ } else {
+ return null;
+ }
}
return DB_OK;
}
@@ -139,7 +129,7 @@
}
unset($this->prepare_tokens[$result]);
unset($this->prepare_types[$result]);
- return true;
+ return true;
}
function numCols($result)