CVS update: /cowiki/includes/cowiki/class/dao/
[email protected] 6 May 2005 02:03:58 -0000
| Newsgroups | gmane.comp.php.cowiki.cvs |
|---|---|
| Message-ID | <[email protected]> |
User: dgorski Date: 2005/05/05 19:03:58 Modified: cowiki/includes/cowiki/class/dao/class.StorageMySQL.php Log: Added several methods File Changes: Directory: /cowiki/includes/cowiki/class/dao/ ============================================= File [changed]: class.StorageMySQL.php Url: http://cowiki.tigris.org/source/browse/cowiki/includes/cowiki/class/dao/class.StorageMySQL.php?r1=1.31&r2=1.32 Delta lines: +99 -11 --------------------- --- class.StorageMySQL.php 3 May 2005 01:02:35 -0000 1.31 +++ class.StorageMySQL.php 6 May 2005 02:03:56 -0000 1.32 @@ -2,7 +2,7 @@ /** * - * $Id: class.StorageMySQL.php,v 1.31 2005/05/03 01:02:35 dgorski Exp $ + * $Id: class.StorageMySQL.php,v 1.32 2005/05/06 02:03:56 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.31 $ + * @version $Revision: 1.32 $ * */ @@ -74,6 +74,14 @@ // -------------------------------------------------------------------- + public function __destruct() { + if ($this->rLink) { + @mysql_close($this->rLink); + } + } + + // -------------------------------------------------------------------- + /** * Connect * @@ -277,11 +285,34 @@ * @since coWiki 0.3.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 @mysql_fetch_assoc($nQueryId); + public function fetchArray($rResource) { + return @mysql_fetch_assoc($rResource); + } + + // -------------------------------------------------------------------- + + /** + * Fetch array and free the occupied memory immediately. + * + * @access public + * @param integer + * @return array + * + * @author Daniel T. Gorski, <[email protected]> + * @since coWiki 0.4.0 + * + * @todo [D11N] Check description + * @todo [D11N] Check the parameter type of "$rResource" + * @todo [D11N] Check return type + */ + public function fetchArrayAndFreeResult($rResource) { + $aData = $this->fetchArray($rResource); + $this->freeResult($rResource); + + return $aData; } // -------------------------------------------------------------------- @@ -297,11 +328,34 @@ * @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($rResource) { + return @mysql_fetch_row($rResource); + } + + // -------------------------------------------------------------------- + + /** + * Fetch array and free the occupied memory immediately. + * + * @access public + * @param integer + * @return array + * + * @author Daniel T. Gorski, <[email protected]> + * @since coWiki 0.4.0 + * + * @todo [D11N] Check description + * @todo [D11N] Check the parameter type of "$rResource" * @todo [D11N] Check return type */ - public function fetchRow($nQueryId) { - return @mysql_fetch_row($nQueryId); + public function fetchRowAndFreeResult($rResource) { + $aData = $this->fetchRow($rResource); + $this->freeResult($rResource); + + return $aData; } // -------------------------------------------------------------------- @@ -317,10 +371,10 @@ * @since coWiki 0.3.0 * * @todo [D11N] Check description - * @todo [D11N] Check the parameter type of "$nQueryId" + * @todo [D11N] Check the parameter type of "$rResource" */ - public function fetchObject($nQueryId) { - $aData = $this->fetchArray($nQueryId); + public function fetchObject($rResource) { + $aData = $this->fetchArray($rResource); if (!is_array($aData)) { return null; @@ -545,6 +599,25 @@ // -------------------------------------------------------------------- /** + * Close current connection + * + * @access public + * @return void + * + * @author Daniel T. Gorski, <[email protected]> + * @since coWiki 0.4.0 + * + * @todo [D11N] Check description + */ + public function close() { + if ($this->rLink) { + @mysql_close($this->rLink); + } + } + + // -------------------------------------------------------------------- + + /** * Begin transaction * * @access public @@ -679,6 +752,21 @@ */ public function getStorageName() { return $this->STORAGE_CONTAINER_NAME; + } + + // -------------------------------------------------------------------- + + /** + * Reload the database (flush privileges) + * + * @access public + * @return string + * + * @author Daniel T. Gorski, <[email protected]> + * @since coWiki 0.4.0 + */ + public function reload() { + $this->query('FLUSH PRIVILEGES'); } } // of class