The PDO Storage class uses the PDO extension for PHP. This allows connection to MySQL, SQLite, PostgreSQL, and many more.


PDO is installed by default in php 5.1+, which is already required for this library, so you’ll be good to go.

Get Started

Once this is done, instantiate a PDO client to connect to your database server of choice.

// connection for MySQL
$pdo = new PDO('mysql:host=localhost;dbname=test', $user, $pass);

// connection for SQLite
$pdo = new PDO('sqlite:/opt/databases/mydb.sq3');

// connection for SQLite in memory
$pdo = new PDO('sqlite::memory:');

Then, create the storage object using the Pdo storage class:

$storage = new OAuth2\Storage\Pdo($pdo);

// now you can perform storage functions, such as the one below
$storage->setClientDetails($client_id, $client_secret, $redirect_uri);


The PDO storage engine implements all the standard Storage Interfaces supported in this library. See interfaces for more information.

Fork me on GitHub