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

[email protected] 3 May 2005 00:45:49 -0000
Newsgroups gmane.comp.php.cowiki.cvs
Message-ID <[email protected]>
User: dgorski 
Date: 2005/05/02 17:45:49

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

Log:
 Added methods to fetch the curren host, port, user and pass
 Added method "fetchRow()"

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.29&r2=1.30
Delta lines:  +132 -2
---------------------
--- class.StorageMySQL.php	2 May 2005 23:27:56 -0000	1.29
+++ class.StorageMySQL.php	3 May 2005 00:45:46 -0000	1.30
@@ -2,7 +2,7 @@
 
 /**
  *
- * $Id: class.StorageMySQL.php,v 1.29 2005/05/02 23:27:56 dgorski Exp $
+ * $Id: class.StorageMySQL.php,v 1.30 2005/05/03 00:45:46 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.29 $
+ * @version     $Revision: 1.30 $
  *
  */
 
@@ -46,6 +46,13 @@
         $aLocked = array(),
         $sLastId = 0;
 
+    protected
+        $sHost = null,
+        $sPort = null,
+        $sUser = null,
+        $sPass = null,
+        $sDb   = null;
+
     // --------------------------------------------------------------------
 
     /**
@@ -93,6 +100,12 @@
             Logger::error('MySQL error '.mysql_errno().': '.mysql_error());
             throw new StorageConnectionFailureException(mysql_error());
         }
+
+        // Remember
+        $this->sHost = $sHost;
+        $this->sPort = $sPort;
+        $this->sUser = $sUser;
+        $this->sPass = $sPass;
     }
 
     // --------------------------------------------------------------------
@@ -119,6 +132,103 @@
 
             throw new StorageDatabaseSelectionException(mysql_error());
         }
+
+        // Remember
+        $this->sDb = $sDatabase;
+    }
+
+    // --------------------------------------------------------------------
+
+    /**
+     * Get current host
+     *
+     * @access  public
+     * @return  string
+     *
+     * @author  Daniel T. Gorski, <[email protected]>
+     * @since   coWiki 0.4.0
+     */
+    public function getHost() {
+        return $this->sHost;
+    }
+
+    // --------------------------------------------------------------------
+
+    /**
+     * Get current host port
+     *
+     * @access  public
+     * @return  string
+     *
+     * @author  Daniel T. Gorski, <[email protected]>
+     * @since   coWiki 0.4.0
+     */
+    public function getHostPort() {
+        return $this->sPort;
+    }
+
+    // --------------------------------------------------------------------
+
+    /**
+     * Get current host and port string
+     *
+     * @access  public
+     * @return  string
+     *
+     * @author  Daniel T. Gorski, <[email protected]>
+     * @since   coWiki 0.4.0
+     */
+    public function getHostString() {
+        if ($this->getHostPort() === null || $this->getHostPort() == '') {
+            return $this->getHost();
+        }
+        
+        return $this->getHost() . ':' . $this->getHostPort();
+    }
+
+    // --------------------------------------------------------------------
+
+    /**
+     * Get current connector user name
+     *
+     * @access  public
+     * @return  string
+     *
+     * @author  Daniel T. Gorski, <[email protected]>
+     * @since   coWiki 0.4.0
+     */
+    public function getUserName() {
+        return $this->sUser;
+    }
+
+    // --------------------------------------------------------------------
+
+    /**
+     * Get current connector user password
+     *
+     * @access  public
+     * @return  string
+     *
+     * @author  Daniel T. Gorski, <[email protected]>
+     * @since   coWiki 0.4.0
+     */
+    public function getUserPassword() {
+        return $this->sPass;
+    }
+
+    // --------------------------------------------------------------------
+
+    /**
+     * Get current database name
+     *
+     * @access  public
+     * @return  string
+     *
+     * @author  Daniel T. Gorski, <[email protected]>
+     * @since   coWiki 0.4.0
+     */
+    public function getDatabase() {
+        return $this->sDb;
     }
 
     // --------------------------------------------------------------------
@@ -171,6 +281,26 @@
      */
     public function fetchArray($nQueryId) {
         return @mysql_fetch_assoc($nQueryId);
+    }
+
+    // --------------------------------------------------------------------
+
+    /**
+     * Fetch row
+     *
+     * @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 "$nQueryId"
+     * @todo    [D11N]  Check return type
+     */
+    public function fetchRow($nQueryId) {
+        return @mysql_fetch_row($nQueryId);
     }
 
     // --------------------------------------------------------------------