cox Tue Mar 27 16:54:05 2001 EDT
Modified files:
/php4/pear/DB ibase.php oci8.php
Log:
oci8.php
* added not capable for fetchInto when $rownum !== null (feature not
supported yet)
* fix fetchInto to return null on no more data
* Removed extra checks in connect()
ibase.php
* removed extra checks in connect() and return error on no connection
* fetchInto now returns NULL on no more data (not tested)
* added not capable for fetchInto when $rownum !== null (feature not
supported yet)
* changed tabs to spaces
Please note that this extension seems to be very old.
Index: php4/pear/DB/ibase.php
diff -u php4/pear/DB/ibase.php:1.17 php4/pear/DB/ibase.php:1.18
--- php4/pear/DB/ibase.php:1.17 Mon Feb 19 04:22:26 2001
+++ php4/pear/DB/ibase.php Tue Mar 27 16:54:05 2001
@@ -16,7 +16,7 @@
// | Authors: Sterling Hughes <[EMAIL PROTECTED]> |
// +----------------------------------------------------------------------+
//
-// $Id: ibase.php,v 1.17 2001/02/19 12:22:26 ssb Exp $
+// $Id: ibase.php,v 1.18 2001/03/28 00:54:05 cox Exp $
//
// Database independent query interface definition for PHP's Interbase
// extension.
@@ -26,172 +26,173 @@
class DB_ibase extends DB_common
{
- var $connection;
- var $phptype, $dbsyntax;
+ var $connection;
+ var $phptype, $dbsyntax;
var $autocommit = 1;
- var $manip_query = array();
+ var $manip_query = array();
- function DB_ibase()
+ function DB_ibase()
{
$this->DB_common();
- $this->phptype = 'ibase';
- $this->dbsyntax = 'ibase';
- $this->features = array(
- 'prepare' => true,
- 'pconnect' => true,
- 'transactions' => true
- );
- }
-
- function connect($dsn, $persistant = false)
- {
- if(is_array($dsn)) {
- $dsninfo = &$dsn;
- } else {
- $dsninfo = DB::parseDSN($dsn);
- }
- if (!$dsninfo || !$dsninfo['phptype']) {
- return $this->raiseError("invalid data source name");
- }
+ $this->phptype = 'ibase';
+ $this->dbsyntax = 'ibase';
+ $this->features = array(
+ 'prepare' => true,
+ 'pconnect' => true,
+ 'transactions' => true
+ );
+ }
+
+ function connect($dsninfo, $persistent = false)
+ {
$this->dsn = $dsninfo;
- $user = $dsninfo['username'];
- $pw = $dsninfo['password'];
- $dbhost = $dsninfo['hostspec'] ?
- ($dsninfo['hostspec'] . ':/' . $dsninfo['database']) :
- $dsninfo['database'];
- $connect_function = $persistent ? 'ibase_pconnect' : 'ibase_connect';
- if ($dbhost && $user && $pw) {
- $conn = $connect_function($dbhost, $user, $pw);
- } elseif ($dbhost && $user) {
- $conn = $connect_function($dbhost, $user);
- } elseif ($dbhost) {
- $conn = $connect_function($dbhost);
- } else {
- return $this->raiseError("no host, user or password");
- }
- $this->connection = $conn;
- return DB_OK;
- }
+ $user = $dsninfo['username'];
+ $pw = $dsninfo['password'];
+ $dbhost = $dsninfo['hostspec'] ?
+ ($dsninfo['hostspec'] . ':/' . $dsninfo['database']) :
+ $dsninfo['database'];
+ $connect_function = $persistent ? 'ibase_pconnect' : 'ibase_connect';
+ if ($dbhost && $user && $pw) {
+ $conn = $connect_function($dbhost, $user, $pw);
+ } elseif ($dbhost && $user) {
+ $conn = $connect_function($dbhost, $user);
+ } elseif ($dbhost) {
+ $conn = $connect_function($dbhost);
+ } else {
+ return $this->raiseError("no host, user or password");
+ }
+ if (!$conn) {
+ return $this->raiseError(DB_ERROR_CONNECT_FAILED);
+ }
+ $this->connection = $conn;
+ return DB_OK;
+ }
- function disconnect()
+ function disconnect()
{
- return @ibase_close($this->connection);
- }
+ return @ibase_close($this->connection);
+ }
- function simpleQuery($query)
+ function simpleQuery($query)
{
- $this->last_query = $query;
+ $this->last_query = $query;
$query = $this->modifyQuery($query);
- $result = @ibase_query($this->connection, $query);
- if (!$result) {
- return $this->raiseError();
- }
+ $result = @ibase_query($this->connection, $query);
+ if (!$result) {
+ return $this->raiseError();
+ }
if ($this->autocommit) {
ibase_commit($this->connection);
}
- // Determine which queries that should return data, and which
- // should return an error code only.
+ // Determine which queries that should return data, and which
+ // should return an error code only.
return DB::isManip($query) ? DB_OK : $result;
- }
+ }
function &fetchRow($result, $fetchmode=DB_FETCHMODE_DEFAULT)
{
- if ($fetchmode == DB_FETCHMODE_DEFAULT) {
- $fetchmode = $this->fetchmode;
- }
- if ($fetchmode & DB_FETCHMODE_ASSOC) {
- $row = (array)ibase_fetch_object($result);
- } else {
- $row = ibase_fetch_row($result);
- }
- if (!$row) {
- if ($errmsg = ibase_errmsg()) {
- return $this->raiseError($errmsg);
- } else {
- return null;
- }
- }
-
- return $row;
- }
-
- function fetchInto($result, &$ar, $fetchmode=DB_FETCHMODE_DEFAULT)
- {
- if ($fetchmode == DB_FETCHMODE_DEFAULT) {
- $fetchmode = $this->fetchmode;
- }
- if ($fetchmode & DB_FETCHMODE_ASSOC) {
- return $this->raiseError(DB_ERROR_NOT_CAPABLE);
- } else {
- $ar = ibase_fetch_row($result);
- }
- if (!$ar) {
- return $this->raiseError();
- }
- return DB_OK;
- }
-
- function freeResult()
- {
- return $this->raiseError(DB_ERROR_NOT_CAPABLE);
- }
-
- function freeQuery($query)
- {
- ibase_free_query($query);
- return true;
- }
-
- function numCols($result)
- {
- $cols = ibase_num_fields($result);
- if (!$cols) {
- return $this->raiseError();
- }
- return $cols;
- }
+ if ($fetchmode == DB_FETCHMODE_DEFAULT) {
+ $fetchmode = $this->fetchmode;
+ }
+ if ($fetchmode & DB_FETCHMODE_ASSOC) {
+ $row = (array)ibase_fetch_object($result);
+ } else {
+ $row = ibase_fetch_row($result);
+ }
+ if (!$row) {
+ if ($errmsg = ibase_errmsg()) {
+ return $this->raiseError($errmsg);
+ } else {
+ return null;
+ }
+ }
+ return $row;
+ }
- function prepare($query)
+ function fetchInto($result, &$ar, $fetchmode=DB_FETCHMODE_DEFAULT, $rownum=null)
{
- $this->last_query = $query;
+ if ($rownum !== NULL) {
+ return $this->raiseError(DB_ERROR_NOT_CAPABLE);
+ }
+ if ($fetchmode == DB_FETCHMODE_DEFAULT) {
+ $fetchmode = $this->fetchmode;
+ }
+ if ($fetchmode & DB_FETCHMODE_ASSOC) {
+ return $this->raiseError(DB_ERROR_NOT_CAPABLE);
+ } else {
+ $ar = ibase_fetch_row($result);
+ }
+ if (!$ar) {
+ if ($errmsg = ibase_errmsg()) {
+ return $this->raiseError($errmsg);
+ } else {
+ return null;
+ }
+ }
+ return DB_OK;
+ }
+
+ function freeResult()
+ {
+ return $this->raiseError(DB_ERROR_NOT_CAPABLE);
+ }
+
+ function freeQuery($query)
+ {
+ ibase_free_query($query);
+ return true;
+ }
+
+ function numCols($result)
+ {
+ $cols = ibase_num_fields($result);
+ if (!$cols) {
+ return $this->raiseError();
+ }
+ return $cols;
+ }
+
+ function prepare($query)
+ {
+ $this->last_query = $query;
$query = $this->modifyQuery($query);
$stmt = ibase_prepare($query);
$this->manip_query[(int)$stmt] = DB::isManip($query);
- return $stmt;
- }
+ return $stmt;
+ }
- function execute($stmt, $data = false)
+ function execute($stmt, $data = false)
{
- $result = ibase_execute($stmt, $data);
- if (!$result) {
- return $this->raiseError();
- }
+ $result = ibase_execute($stmt, $data);
+ if (!$result) {
+ return $this->raiseError();
+ }
if ($this->autocommit) {
ibase_commit($this->connection);
}
- return DB::isManip($this->manip_query[(int)$stmt]) ? DB_OK : $result;
- }
+ return DB::isManip($this->manip_query[(int)$stmt]) ? DB_OK : $result;
+ }
- function autoCommit($onoff = false)
+ function autoCommit($onoff = false)
{
$this->autocommit = $onoff ? 1 : 0;
- return DB_OK;
- }
+ return DB_OK;
+ }
- function commit()
+ function commit()
{
- return ibase_commit($this->connection);
- }
+ return ibase_commit($this->connection);
+ }
- function rollback($trans_number)
+ function rollback($trans_number)
{
- return ibase_rollback($this->connection, $trans_number);
- }
+ return ibase_rollback($this->connection, $trans_number);
+ }
- function transactionInit($trans_args = 0)
+ function transactionInit($trans_args = 0)
{
- return $trans_args ? ibase_trans($trans_args, $this->connection) :
ibase_trans();
- }
+ return $trans_args ? ibase_trans($trans_args, $this->connection) :
+ibase_trans();
+ }
}
/*
Index: php4/pear/DB/oci8.php
diff -u php4/pear/DB/oci8.php:1.21 php4/pear/DB/oci8.php:1.22
--- php4/pear/DB/oci8.php:1.21 Thu Mar 22 17:15:06 2001
+++ php4/pear/DB/oci8.php Tue Mar 27 16:54:05 2001
@@ -80,16 +80,8 @@
*
* @return int DB_OK on success, a DB error code on failure
*/
- 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(DB_ERROR_INVALID_DSN);
- }
$this->dsn = $dsninfo;
$user = $dsninfo['username'];
$pw = $dsninfo['password'];
@@ -186,7 +178,7 @@
}
return $row;
}
-
+
// }}}
// {{{ fetchInto()
@@ -196,11 +188,15 @@
* @param $result oci8 result identifier
* @param $arr (reference) array where data from the row is stored
* @param $fetchmode how the array data should be indexed
+ * @param $rownum the row number to fetch (not yet supported)
*
* @return int DB_OK on success, a DB error code on failure
*/
- function fetchInto($result, &$arr, $fetchmode = DB_FETCHMODE_DEFAULT)
+ function fetchInto($result, &$arr, $fetchmode = DB_FETCHMODE_DEFAULT,
+$rownum=NULL)
{
+ if ($rownum !== NULL) {
+ return $this->raiseError(DB_ERROR_NOT_CAPABLE);
+ }
if ($fetchmode == DB_FETCHMODE_DEFAULT) {
$fetchmode = $this->fetchmode;
}
@@ -209,8 +205,8 @@
} else {
$moredata = @OCIFetchInto($result,$arr,OCI_RETURN_NULLS+OCI_RETURN_LOBS);
}
- if (!($arr && $moredata)) {
- return $this->oci8RaiseError($result);
+ if (!$moredata) {
+ return NULL;
}
return DB_OK;
}
@@ -236,7 +232,7 @@
unset($this->prepare_tokens[$result]);
unset($this->prepare_types[$result]);
unset($this->manip_query[$result]);
- return true;
+ return true;
}
// }}}
@@ -407,7 +403,7 @@
/**
* Enable/disable automatic commits
- *
+ *
* @param $onoff true/false whether to autocommit
*/
function autoCommit($onoff = false)
@@ -502,7 +498,7 @@
* @access public
*
* @param $seq_name the name of the sequence
- *
+ *
* @param $ondemand whether to create the sequence table on demand
* (default is true)
*
@@ -531,7 +527,7 @@
$arr = $result->fetchRow(DB_FETCHMODE_ORDERED);
return $arr[0];
}
-
+
// }}}
// {{{ createSequence()
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]