Aura.Sql Can Now Make Use of Existing PDO Connection

Dec 6th, 2012

Aura.Sql can now make use of an existing PDO connection with the recent commit here . This all came after a short discussion with Stan Lemon. A big Thanks to him for making a featured request like this. > @harikt can I inject an existing Pdo > object? > > — Stan Lemon (@stanlemon) > December 1, 2012 How to make use of an existing PDO? You want to get a connection object and set the instance of pdo. Note : In this way you are eager loading the PDO. Else Aura.Sql knows when to do the connection. Example of how to make use of it is

123456789101112131415

useAura\Sql\ConnectionFactory;$connection_factory=newConnectionFactory;$connection=$connection_factory->newInstance(// connection name 'mysql',// DSN elements for PDO; this can also be // an array of key-value pairs // host=127.0.0.1;dbname=database-name '',// username for the connection '',// password for the connection '');$connection->setPdo($pdo);

Normally you need to pass the dsn as a string or array. But if you are having the PDO object and you don’t love to do, you can pass it as null. Then to the connection object set the pdo instance. Now you can make use of the Aura.Sql insert ,update , delete queries. For a detailed information of how to do check the docs at Aura.Sql . Assuming you have a PDO object created something like the one below