cox             Mon Mar 26 16:57:25 2001 EDT

  Modified files:              
    /php4/pear/DB       common.php ifx.php pgsql.php 
  Log:
  ifx.php
  * Changed default fetchmode to ORDERED
  * Remove extra checks in connect and added $dns property
  * fetchRow() now uses fetchInto()
  
  common.php & pgsql.php
  style
  
  
Index: php4/pear/DB/common.php
diff -u php4/pear/DB/common.php:1.41 php4/pear/DB/common.php:1.42
--- php4/pear/DB/common.php:1.41        Fri Mar 23 23:00:45 2001
+++ php4/pear/DB/common.php     Mon Mar 26 16:57:24 2001
@@ -51,9 +51,8 @@
 
     function toString()
     {
-       $info = get_class($this);
-        
-       $info .=  ": (phptype=" . $this->phptype .
+        $info = get_class($this);
+        $info .=  ": (phptype=" . $this->phptype .
                   ", dbsyntax=" . $this->dbsyntax .
                   ")";
 
@@ -229,7 +228,7 @@
             case PEAR_ERROR_TRIGGER:
             case PEAR_ERROR_DIE:
                 $this->error_mode = $mode;
-                
+
                 if (!$options) {
                     $this->error_level = E_USER_NOTICE;
                 } else {
@@ -322,10 +321,10 @@
 
         for ($i = 0; $i < strlen($query); $i++) {
             switch ($query[$i]) {
-                case "?":
+                case '?':
                     $types[$token++] = DB_PARAM_SCALAR;
                     break;
-                case "&":
+                case '&':
                     $types[$token++] = DB_PARAM_OPAQUE;
                     break;
             }
@@ -372,18 +371,18 @@
             !sizeof($this->prepare_tokens[$stmt])) {
             return $this->raiseError(DB_ERROR_INVALID);
         }
-        
+
         $qq = &$this->prepare_tokens[$stmt];
         $qp = sizeof($qq) - 1;
-        
+
         if ((!$data && $qp > 0) ||
             (!is_array($data) && $qp > 1) ||
             (is_array($data) && $qp > sizeof($data))) {
             return $this->raiseError(DB_ERROR_NEED_MORE_DATA);
         }
-        
+
         $realquery = $qq[0];
-        
+
         for ($i = 0; $i < $qp; $i++) {
             if ($this->prepare_types[$stmt][$i] == DB_PARAM_OPAQUE) {
                 if (is_array($data)) {
@@ -629,7 +628,7 @@
         if (isset($sth)) {
             $this->freeResult($sth);
         }
- 
+
         return $ret;
     }
 
Index: php4/pear/DB/ifx.php
diff -u php4/pear/DB/ifx.php:1.3 php4/pear/DB/ifx.php:1.4
--- php4/pear/DB/ifx.php:1.3    Sun Mar 25 02:34:31 2001
+++ php4/pear/DB/ifx.php        Mon Mar 26 16:57:24 2001
@@ -33,7 +33,8 @@
     var $numrows;
     var $row;
     var $affected = 0;
-    var $fetchmode = DB_FETCHMODE_ASSOC; /* Default fetch mode */
+    var $dsn = array();
+    var $fetchmode = DB_FETCHMODE_ORDERED; /* Default fetch mode */
 
     function DB_ifx()
     {
@@ -54,7 +55,7 @@
             '-1206'   => DB_ERROR_INVALID_DATE,
             '-1209'   => DB_ERROR_INVALID_DATE,
             '-1210'   => DB_ERROR_INVALID_DATE,
-            '-1212'   => DB_ERROR_INVALID_DATE 
+            '-1212'   => DB_ERROR_INVALID_DATE
        );
     }
 
@@ -67,9 +68,9 @@
      *
      * @return int DB_OK on success, a DB error code on failure
      */
-    function connect(&$dsn, $persistent = false)
+    function connect(&$dsninfo, $persistent = false)
     {
-        $dsninfo = DB::parseDSN($dsn);
+        $this->dsn = $dsninfo;
         $dbhost = $dsninfo['hostspec'] ? '@' . $dsninfo['hostspec'] : '';
         $dbname = $dsninfo['database'] ? $dsninfo['database'] . $dbhost : '';
         $user = $dsninfo['username'] ? $dsninfo['username'] : '';
@@ -137,33 +138,56 @@
     }
 
     /**
+     * Fetch and return a row of data (it uses fetchInto for that)
+     * @param   $result             Informix result identifier
+     * @param   $fetchmode     format of fetched row array
+     * @param   $rownum        the absolute row number to fetch
+     *
+     * @return  array   a row of data, or false on error
+     */
+    function fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=0)
+    {
+        if ($fetchmode == DB_FETCHMODE_DEFAULT) {
+            $fetchmode = $this->fetchmode;
+        }
+        $res = $this->fetchInto ($result, $arr, $fetchmode, $rownum);
+        if ($res !== DB_OK) {
+            return $res;
+        }
+        return $arr;
+    }
+
+    /**
      * Fetch a row and return as array.
      *
-     * @param $result Informix result identifier
-     * @param $fetchmode how the resulting array should be indexed
-     * @param $rownum the row number to fetch
+     * @param   $result     Informix result identifier
+     * @param   $row         (reference) array where data from the row is stored
+     * @param   $fetchmode      how the resulting array should be indexed
+     * @param   $rownum     the row number to fetch
      *
      * @return int an array on success, a DB error code on failure, NULL
      *             if there is no more data
      */
-    function &fetchRow($result, $fetchmode, $rownum=null)
+    function fetchInto($res, &$row, $fetchmode, $rownum=0)
     {
-        $rownum = (!empty($rownum) && ($rownum > 0)) ? $rownum : null;
+        $rownum = ($rownum > 0) ? $rownum : null;
         if (!$row = @ifx_fetch_row($result, $rownum)) {
             return NULL;
         }
         switch ($fetchmode){
             case DB_FETCHMODE_ASSOC:
-                return $row;
+                break;
             case DB_FETCHMODE_ORDERED:
                 $i=0;
                 foreach ($row as $key => $val) {
                     $order[$i++] = $val;
                 }
-                return $order;
+                $row = $order;
+                break;
             default:
                 return $this->raiseError(DB_ERROR_UNSUPPORTED);
         }
+        return DB_OK;
     }
 
     function numRows($result)
@@ -199,11 +223,6 @@
             return $this->ifxraiseError();
         }
         return true;
-    }
-
-    function fetchInto($res, &$arr, $mode)
-    {
-        return $this->raiseError(DB_ERROR_UNSUPPORTED);
     }
 
     function ifxraiseError($errno = null)
Index: php4/pear/DB/pgsql.php
diff -u php4/pear/DB/pgsql.php:1.32 php4/pear/DB/pgsql.php:1.33
--- php4/pear/DB/pgsql.php:1.32 Mon Mar 26 15:31:50 2001
+++ php4/pear/DB/pgsql.php      Mon Mar 26 16:57:24 2001
@@ -219,10 +219,10 @@
     /**
      * Fetch and return a row of data (it uses fetchInto for that)
      * @param $result PostgreSQL result identifier
-    * @param   $fetchmode  format of fetched row array
+     * @param   $fetchmode  format of fetched row array
      * @param   $rownum     the absolute row number to fetch
-    *
-    * @return  array   a row of data, or false on error
+     *
+     * @return  array   a row of data, or false on error
      */
     function fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=0)
     {



-- 
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]

Reply via email to