From 943c65bd46006be6521d9d7f0b954ee1a8874217 Mon Sep 17 00:00:00 2001 From: Guillermo Dev Date: Mon, 15 Oct 2018 23:55:25 +0200 Subject: [PATCH] Connection is now using Gbili\Db\Req\Req underneath --- boot/bootstrap.php | 5 +++++ composer.json | 7 ++++++- src/Db/Connection.php | 45 +++++++++++++------------------------------ 3 files changed, 24 insertions(+), 33 deletions(-) create mode 100644 boot/bootstrap.php diff --git a/boot/bootstrap.php b/boot/bootstrap.php new file mode 100644 index 0000000..6ae3945 --- /dev/null +++ b/boot/bootstrap.php @@ -0,0 +1,5 @@ +is_error()) { - if($throw_error) { - throw new SqlException($result->get_error(), $query); - } - - return $result->get_error(); + if (null === self::$req) { + self::$req = new Req(); } - - return $result; + return self::$req->getResultSet($sql, $values); } + /** + * @return PDO connection + */ public static function get() { - if (is_null(self::$db)) { - $dsn = sprintf( - "Driver={%s};Server=%s,%s;Database=%s;", - Configuration::get('db.driver'), - Configuration::get('db.server'), - Configuration::get('db.port'), - Configuration::get('db.name') - ); - self::$db = odbc_pconnect($dsn, Configuration::get('db.username'), Configuration::get('db.password')); - - if (self::$db === false) { - throw new SqlException("Unable to connect to the server."); - } - } - // Return the connection - return self::$db; + return self::$req->getAdapter(); } final private function __clone() {}