Exemplo n.º 1
0
class MyApplication
{
    private $_settings;
    private $_dbConnection;
    private $_dbQueryBuilder;
    private $_dbSchema;
    public function __construct($settings)
    {
        $this->_settings = $settings;
        switch ($this->_settings['dbDriver']) {
            case 'mysql':
                $factory = new MySQLFactory();
                break;
            case 'oracle':
                $factory = new OracleFactory();
                break;
        }
        $this->_dbConnection = $factory->createDBConnection();
        $this->_dbQueryBuilder = $factory->createDBQueryBuilder();
        $this->_dbSchema = $factory->createDBSchema();
    }
    public function run()
    {
        $this->_dbConnection->getConnection();
        $this->_dbQueryBuilder->getQuery();
        $this->_dbSchema->getSchema();
    }
}
$myApp = new MyApplication(array('dbDriver' => 'mysql'));
$myApp->run();