[pLog-svn] r2403 - plog/branches/plog-1.1-daochanges/class/database/pdb

ork at devel.plogworld.net ork at devel.plogworld.net
Mon Aug 8 18:39:37 GMT 2005


Author: ork
Date: 2005-08-08 18:39:36 +0000 (Mon, 08 Aug 2005)
New Revision: 2403

Modified:
   plog/branches/plog-1.1-daochanges/class/database/pdb/pdb.class.php
Log:
added listValidDrivers() and changed a few lines.. we need listValidDrivers() to add a list of valid dbs on the first page of the wizard.php..


Modified: plog/branches/plog-1.1-daochanges/class/database/pdb/pdb.class.php
===================================================================
--- plog/branches/plog-1.1-daochanges/class/database/pdb/pdb.class.php	2005-08-08 17:57:58 UTC (rev 2402)
+++ plog/branches/plog-1.1-daochanges/class/database/pdb/pdb.class.php	2005-08-08 18:39:36 UTC (rev 2403)
@@ -1,82 +1,96 @@
 <?php
     /**
-	 * \defgroup PDb
-	 */
-	 
-	include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
-	
-	define( "PDB_DRIVER_FOLDER", PLOG_CLASS_PATH."class/database/pdb/drivers/" );
-	
-    /**
-     * how many items per page by default, when paging is enabled
-     */
-    define( "DEFAULT_ITEMS_PER_PAGE", 15 );
-    
-    /**
-     * whether we're going to use paging or not.
-     */
-    define( "DEFAULT_PAGING_ENABLED", -1 );	
-
-	/**
-	 * PDb
-	 *
-	 * Plog's own lightweight database abstraction layer
-	 *
-	 * \ingroup PDb
-	 */
-	class PDb extends Object
-	{
-		var $_drivers;
-	
-		function PDb()
-		{
-			$this->Object();
-		}
-		
-		/**
-		 * return the right driver type
-		 *
-		 * @param driver the driver name. Supported types are
-		 *
-		 * - mysql
-		 *
-		 * @return An object of a class extending the PDbDriverBase class that implements the requested
-		 * database access.
-		 * @see PDbDriverBase
-		 */
-		function getDriver( $driver )
-		{
-			$drivers = Array( 
-			   "mysql" => "PDbMySQLDriver",
-			   "dbx" => "PDbDbxDriver" );			
-			
-			// load the driver class
-			$driverPath = PDB_DRIVER_FOLDER.strtolower( $drivers[$driver] ).".class.php";
-			include_once( $driverPath );
-			
-			// create an instance of it
-			$driverClass = new $drivers[$driver]();
-			
-			return( $driverClass );
-		}
-	}
-	
-	/**
-	 * ADOdb compatibility
-	 *
-	 * @param driver A driver class whose data dictionary class we'd like to get. This method is obsolete
-	 * and you should call PDbDriverBase::getDriverDataDictionary(). This method is only here for compatibility
-	 * reasons.
-	 *
-	 * @see PDbDriverBase::getDriverDataDictionary()	 
-	 * @deprecated
-	 */
+     * \defgroup PDb
+     */
+     
+    include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
+    
+    define( "PDB_DRIVER_FOLDER", PLOG_CLASS_PATH."class/database/pdb/drivers/" );
+    
+    /**
+     * how many items per page by default, when paging is enabled
+     */
+    define( "DEFAULT_ITEMS_PER_PAGE", 15 );
+    
+    /**
+     * whether we're going to use paging or not.
+     */
+    define( "DEFAULT_PAGING_ENABLED", -1 ); 
+
+    /**
+     * PDb
+     *
+     * Plog's own lightweight database abstraction layer
+     *
+     * \ingroup PDb
+     */
+    class PDb extends Object
+    {
+        function PDb()
+        {
+            $this->Object();
+        }
+        
+        /**
+         * return the right driver type
+         *
+         * @param driver the driver name. Supported types are
+         *
+         * - mysql
+         *
+         * @return An object of a class extending the PDbDriverBase class that implements the requested
+         * database access.
+         * @see PDbDriverBase
+         */
+        function getDriver( $driver )
+        {
+            $validDrivers = PDb::getValidDrivers();
+
+            print_r($validDrivers);
+
+            if( array_key_exists($driver, $validDrivers) ) {
+                // load the driver class
+                $driverPath = PDB_DRIVER_FOLDER.strtolower( $validDrivers[$driver] ).".class.php";
+                include_once( $driverPath );
+                
+                // create an instance of it
+                $driverClass = new $validDrivers[$driver]();
+                
+                return( $driverClass );
+            } else {
+                return false;
+            }
+        }
+
+        function getValidDrivers() {
+            $_drivers = Array( "mysql"    => "PDbMySQLDriver",
+                               "postgres" => "PDbPostgresDriver",
+                               "dbx"      => "PDbDbxDriver" );           
+    
+            return $_drivers;
+        }
+
+        function listDrivers() {
+            return array_keys( PDb::getValidDrivers() );
+        }
+    }
+    
+    /**
+     * ADOdb compatibility
+     *
+     * @param driver A driver class whose data dictionary class we'd like to get. This method is obsolete
+     * and you should call PDbDriverBase::getDriverDataDictionary(). This method is only here for compatibility
+     * reasons.
+     *
+     * @see PDbDriverBase::getDriverDataDictionary()     
+     * @deprecated
+     */
     function NewDataDictionary( $driver )
     {
-		$false = false;
+        $false = false;
 
-		//include_once(ADODB_DIR.'/adodb-datadict.inc.php');
-		//include_once( PLOG_CLASS_PATH."class/database/pdb/datadict/pdbdatadict.class.php" );
-		return( $driver->getDriverDataDictionary());
-    }
-?>
\ No newline at end of file
+        //include_once(ADODB_DIR.'/adodb-datadict.inc.php');
+        //include_once( PLOG_CLASS_PATH."class/database/pdb/datadict/pdbdatadict.class.php" );
+        return( $driver->getDriverDataDictionary());
+    }
+?>




More information about the pLog-svn mailing list