Created
July 24, 2009 15:45
-
-
Save rmehner/154378 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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