Skip to content

Instantly share code, notes, and snippets.

@rmehner
Created July 24, 2009 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmehner/154378 to your computer and use it in GitHub Desktop.
Save rmehner/154378 to your computer and use it in GitHub Desktop.
<?php
class ObjectWithDatabase
{
private $_db;
public function __construct( Database_Interface $database = null )
{
if ($database === null) {
$this->_db = new Database_Mysql();
} else {
$this->_db = $database;
}
}
}
$database = new Database_Sqlite();
$obj = new ObjectWithDatabase( $database );
// without params: default adapter
$obj = new ObjectWithDatabase();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment