%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php /** * \brief This class contains Database Connection details * \n Features: * \li Create Database Object * \li Get Database Object * \li Close Connection * \n * \author Jayshri Kinge * \version 1.0 * \date 04/03/2015 * \note (C) 2015 Fermion Infotech Private Limited. All rights reserved. (info@fermion.in) */ final class DbConn{ private static $connections = array(); /**< Array $connections contains Array */ /** * _construct don't permit an explicit call of the constructor! (like $v = new Singleton()) */ private function __construct() { } /** * _clone don't permit cloning the singleton (like $x = clone $v) */ private function __clone() { } /** * getDBObject gets connection object to create link with database * @param Array $database contains the details of the database * <p> This function checks that already connected with database or not, otherwise calls createDBObject method to create connection</p> * @return Connection Object. */ public static function getDBObject($database){ if(empty(self::$connections[$database])){ self::$connections[$database] = self::createDBObject($database); mysqli_set_charset(self::$connections[$database], 'utf8'); } return self::$connections[$database]; } public static function setTimeZone($timezone, $database) { $query = 'SET time_zone = \'' . $timezone . '\''; self::$connections[$database]->query($query); } /** * createDBObject creates connection object to create link with database * @param Array $database contains the details of the database * <p> This function create connection with database by using mysqli method</p> * @return Connection Object if successfully connected. */ private static function createDBObject($database) { global $databases; try { return new mysqli($databases[$database]['host'], $databases[$database]['user'], $databases[$database]['password'], $databases[$database]['database']); //return new mysqli($databases['2']['host'], $databases['2']['user'], $databases['2']['password'], $databases['2']['database']); } catch (Exception $err){ $sysErr = 'Message: ' .$err->getMessage(); $custErr = 'Error in file: '.__FILE__.', Line: '.__LINE__; error_log($sysErr . "\n" . $custErr); } } /** * closeConnections closes database connection * @param : No parameters * <p> This function closes database connection</p> * @return void */ public static function closeConnections() { try { foreach(self::$connections as $connection) { try { $connection->close(); } catch(Exception $closeErr) {} } self::$connections = null; } catch(Exception $err) { echo $err->getMessage(); } } }