Example #1
0
 public static function conn()
 {
     if (self::$_db) {
         return self::$_db;
     } else {
         self::$_db = new mysqli('', $user, $password, $database, $port, $socket);
         return self::$_db;
     }
 }
 /**
  *	Builds the Database singleton class to be used as a wrapper against the
  * 	database and its internals.  Specifically, this constructor builds the
  *	PDO object we'll use in this class.
  *
  *	This constructor will never be used by the outside; rather it will only
  * 	be used by the method who's task is to instantiate this singleton.
  *
  *	@param		$dbLoc		Location of the MySQL database.
  *	@param		$dbName		Name of the database being used.
  *	@param		$dbUser		Username with access to database.
  *	@param		$dbPass		Password for the database user.
  */
 private function __construct($dbLoc, $dbName, $dbUser, $dbPass)
 {
     self::$_db = new PDO(sprintf("mysql: server=%s; dbname=%s", $dbLoc, $dbName), $dbUser, $dbPass);
 }
Example #3
0
 public function __construct($db, $user, $password, $host = "localhost")
 {
     self::$_db = new Mysql($host, $db, $user, $password);
 }