1
0
Fork 0
oldhaven/php/core/classes/db/Db.class.php

40 lines
756 B
PHP
Raw Normal View History

2011-03-31 02:01:16 +00:00
<?php
class Db extends Singleton {
private $_driver;
public function init() {
$params = Config::get('app:DB');
$driver = $params['engine'];
unset($params['engine']);
switch ($driver) {
case 'pgsql' : default :
$this->_driver = new Pgsql(); break;
}
call_user_func_array(array($this->_driver, 'connect'), $params);
}
public function q($q, $params = array()) {
if (! $this->_driver) {
$this->init();
}
return $this->_driver->q($q);
}
public function getRows($result, $key = false) {
if (! $this->_driver) {
$this->init();
}
return $this->_driver->getRows($result, $key);
}
public function getRow($result) {
if (! $this->_driver) {
$this->init();
}
return $this->_driver->getRow($result);
}
}
?>