/** * @param $namespace * @param $database * * @return DB * @throws DB\Exception */ private static function init($namespace, $database) { $installed_drivers = DB\Connection::getAvailableDrivers(); /** @var DB\Driver\DriverInterface $driver_class */ $driver_class = self::getDriverClass($database->driver); //Check PDO driver is installed on system if (!in_array($driver_class::getDriverName(), $installed_drivers)) { throw new DBException(sprintf('PDO::%s driver not installed for %s.', $driver_class::getDriverName(), $driver_class)); } self::$num_databases++; $instance = new self($namespace, $database); Hook::triggerAction('db.after_init', array(&$instance)); return $instance; }
/** * Execute a basic statement on the current connection and return the PDO statement object * * @param $sql * @param array $params * * @return \PDOStatement */ public function statement($sql, array $params = array()) { $statement = $this->connection->prepare($sql); $statement->execute($params); return $statement; }