Hi guys..

Just played around with PDO and it was remarkable that you can't pass
the username and password via dsn to the mysql-driver.
Also in the database.ini is no hint that PDODatabase exists.

Here is my little patch to solve these things


Benny
Index: src/database/PDODatabase.class.php
===================================================================
--- src/database/PDODatabase.class.php	(revision 266)
+++ src/database/PDODatabase.class.php	(working copy)
@@ -64,12 +64,13 @@
 		}
 
 		try	{
+			$pdo_username = $this->getParameter('username');
+			$pdo_password = $this->getParameter('password');
+			$this->connection = new PDO($dsn, $pdo_username, $pdo_password);
 
-			$this->connection = new PDO($dsn);
-
 		} catch (PDOException $e)	{
 
-			throw new DatabaseException($e->getMessage());	
+			throw new DatabaseException($e->getMessage());
 
 		}
 
Index: samples/webapp/config/databases.ini
===================================================================
--- samples/webapp/config/databases.ini	(revision 266)
+++ samples/webapp/config/databases.ini	(working copy)
@@ -150,7 +150,21 @@
 ; |                                                                            |
 ; |         ; the following two are optional                                   |
 ; |         param.datasource = "another_datasource_in_the_runtime_config"      |
-; |         param.use_as_default = true                                        |
+; |         param.use_as_default = true    									   |
+; |                                                                            |
+; | Standard PDO setup with host and database                                  |
+; |                                                                            |
+; |      [DBName]                                                              |
+; |          class = "PDODatabase"                                             |
+; |                                                                            |
+; |          param.dsn = "mysql:dbname=testdb;host=localhost" 				   |
+; |                                                                            |
+; |         ; the following two are optional for some pdo-drivers              |
+; |          param.username = "joe"                                            |
+; |          param.password = "secret"                                         |
+; |                                                                            |
+; |                                                                            |
+; |                                                                            |
 ; | -------------------------------------------------------------------------- |
 ; | PARAMETER KEYS:                                                            |
 ; |                                                                            |
_______________________________________________
agavi-dev mailing list
[email protected]
http://labworkz.com/cgi-bin/mailman/listinfo/agavi-dev

Reply via email to