/**
  * Initialize single MySQLDriver object.
  * Singleton pattern implementation.
  * 
  * @return MySQLDriver Single instance of a MySQLDriver object.
  */
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new MySQLDriver();
     }
     return self::$instance;
 }
Esempio n. 2
0
<?php

// all necessary settings are included
include 'app/config/init.php';
// class autoloading is started
Autoloader::init();
// application registry initializes
$registry = new Registry();
// core components loading
$registry->session = Session::getInstance();
$registry->db = MySQLDriver::getInstance();
$registry->request = RequestHandler::getInstance();
$registry->dao = new DAOFactory($registry);
$registry->router = Router::getInstance($registry);
$registry->template = new Template($registry);
// application is started
$registry->router->loader();
Esempio n. 3
0
 /**
  * Connects to a MySQL database
  *
  * @access public
  * @return  void
  */
 public function connect()
 {
     try {
         self::$_link = mysql_connect($this->host, $this->user, $this->password);
         $this->select();
         if (self::$_link === false) {
             throw new Exception("No he podido conectar al servidor MySQL. ");
         }
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }