CVS update: /cowiki/includes/cowiki/class/dao/

[email protected] 12 May 2005 21:40:27 -0000
Newsgroups gmane.comp.php.cowiki.cvs
Message-ID <[email protected]>
User: dgorski 
Date: 2005/05/12 14:40:27

Modified:
   cowiki/includes/cowiki/class/dao/class.StorageMySQLi.php
   cowiki/includes/cowiki/class/dao/class.StorageMySQL.php

Log:
 Free the occupied memory after the last data has been fetched with fetchArray()/fetchRow()

File Changes:

Directory: /cowiki/includes/cowiki/class/dao/
=============================================

File [changed]: class.StorageMySQLi.php
Url: http://cowiki.tigris.org/source/browse/cowiki/includes/cowiki/class/dao/class.StorageMySQLi.php?r1=1.17&r2=1.18
Delta lines:  +24 -12
---------------------
--- class.StorageMySQLi.php	12 May 2005 19:48:04 -0000	1.17
+++ class.StorageMySQLi.php	12 May 2005 21:40:25 -0000	1.18
@@ -2,7 +2,7 @@
 
 /**
  *
- * $Id: class.StorageMySQLi.php,v 1.17 2005/05/12 19:48:04 dgorski Exp $
+ * $Id: class.StorageMySQLi.php,v 1.18 2005/05/12 21:40:25 dgorski Exp $
  *
  * This file is part of coWiki. coWiki is free software under the terms of
  * the GNU General Public License (GPL). Read the LICENSE file. If you did
@@ -17,7 +17,7 @@
  * @author      Daniel T. Gorski, <[email protected]>
  * @copyright   (C) Daniel T. Gorski, {@link http://www.develnet.org}
  * @license     http://www.gnu.org/licenses/gpl.html
- * @version     $Revision: 1.17 $
+ * @version     $Revision: 1.18 $
  *
  */
 
@@ -195,7 +195,8 @@
     // --------------------------------------------------------------------
 
     /**
-     * Fetch array. Overwrite the parent method.
+     * Fetch one single result array and free the occupied memory
+     * immediately.
      *
      * @access  public
      * @param   integer
@@ -205,17 +206,23 @@
      * @since   coWiki 0.4.0
      *
      * @todo    [D11N]  Check description
-     * @todo    [D11N]  Check the parameter type of "$nQueryId"
+     * @todo    [D11N]  Check the parameter type of "$rResource"
      * @todo    [D11N]  Check return type
      */
-    public function fetchArray($nQueryId) {
-        return @mysqli_fetch_assoc($nQueryId);
+    public function fetchArray($rResource) {
+        $mData = @mysqli_fetch_assoc($rResource);
+        if ($mData === false) {
+            $this->freeResult($rResource);
+        }
+    
+        return $mData;
     }
 
     // --------------------------------------------------------------------
 
     /**
-     * Fetch row
+     * Fetch one single result row and free the occupied memory
+     * immediately.
      *
      * @access  public
      * @param   integer
@@ -225,11 +232,16 @@
      * @since   coWiki 0.4.0
      *
      * @todo    [D11N]  Check description
-     * @todo    [D11N]  Check the parameter type of "$nQueryId"
+     * @todo    [D11N]  Check the parameter type of "$rResource"
      * @todo    [D11N]  Check return type
      */
-    public function fetchRow($nQueryId) {
-        return @mysqli_fetch_row($nQueryId);
+    public function fetchRow($rResource) {
+        $mData = @mysqli_fetch_row($rResource);
+        if ($mData === false) {
+            $this->freeResult($rResource);
+        }
+    
+        return $mData;
     }
 
     // --------------------------------------------------------------------
@@ -265,8 +277,8 @@
      *
      * @todo    [D11N]  Check description
      */
-    public function freeResult($rResult) {
-        @mysqli_free_result($rResult);
+    public function freeResult($rResource) {
+        @mysqli_free_result($rResource);
     }
 
     // --------------------------------------------------------------------

File [changed]: class.StorageMySQL.php
Url: http://cowiki.tigris.org/source/browse/cowiki/includes/cowiki/class/dao/class.StorageMySQL.php?r1=1.35&r2=1.36
Delta lines:  +22 -8
--------------------
--- class.StorageMySQL.php	12 May 2005 19:47:28 -0000	1.35
+++ class.StorageMySQL.php	12 May 2005 21:40:25 -0000	1.36
@@ -2,7 +2,7 @@
 
 /**
  *
- * $Id: class.StorageMySQL.php,v 1.35 2005/05/12 19:47:28 dgorski Exp $
+ * $Id: class.StorageMySQL.php,v 1.36 2005/05/12 21:40:25 dgorski Exp $
  *
  * This file is part of coWiki. coWiki is free software under the terms of
  * the GNU General Public License (GPL). Read the LICENSE file. If you did
@@ -17,7 +17,7 @@
  * @author      Daniel T. Gorski, <[email protected]>
  * @copyright   (C) Daniel T. Gorski, {@link http://www.develnet.org}
  * @license     http://www.gnu.org/licenses/gpl.html
- * @version     $Revision: 1.35 $
+ * @version     $Revision: 1.36 $
  *
  */
 
@@ -299,13 +299,19 @@
      * @todo    [D11N]  Check return type
      */
     public function fetchArray($rResource) {
-        return @mysql_fetch_assoc($rResource);
+        $mData = @mysql_fetch_assoc($rResource);
+        if ($mData === false) {
+            $this->freeResult($rResource);
+        }
+    
+        return $mData;
     }
 
     // --------------------------------------------------------------------
 
     /**
-     * Fetch array and free the occupied memory immediately.
+     * Fetch one single result array and free the occupied memory
+     * immediately.
      *
      * @access  public
      * @param   integer
@@ -342,13 +348,19 @@
      * @todo    [D11N]  Check return type
      */
     public function fetchRow($rResource) {
-        return @mysql_fetch_row($rResource);
+        $mData = @mysql_fetch_row($rResource);
+        if ($mData === false) {
+            $this->freeResult($rResource);
+        }
+    
+        return $mData;
     }
 
     // --------------------------------------------------------------------
 
     /**
-     * Fetch array and free the occupied memory immediately.
+     * Fetch one single result row and free the occupied memory
+     * immediately.
      *
      * @access  public
      * @param   integer
@@ -574,8 +586,8 @@
      *
      * @todo    [D11N]  Check description
      */
-    public function freeResult($rResult) {
-        @mysql_free_result($rResult);
+    public function freeResult($rResource) {
+        @mysql_free_result($rResource);
     }
 
     // --------------------------------------------------------------------
@@ -615,6 +627,7 @@
      */
     public function begin() {
         if ($this->nTrans == 0) {
+
             // {{{ DEBUG }}}
             Logger::sql('BEGIN');
 
@@ -650,6 +663,7 @@
         }
 
         if ($this->nTrans == 0) {
+
             // {{{ DEBUG }}}
             Logger::sql('COMMIT');