public static function get()
 {
     if (is_null(self::$instance)) {
         self::$instance = self::openConnection();
     }
     return self::$instance;
 }
예제 #2
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new Connection();
     }
     return self::$instance;
 }
예제 #3
0
 /**
  * Get a singleton instance of Connection<object>
  *
  * @return Connection
  */
 public static function get_instance()
 {
     if (self::$instance === null) {
         self::$instance = new Connection();
     }
     return self::$instance;
 }
 public static function open()
 {
     if (self::$instance == null) {
         $klass = __CLASS__;
         self::$instance = new $klass('localhost', 'root', "", 'impaz');
     }
     return self::$instance;
 }
예제 #5
0
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new self(self::HOST, self::USER, self::PASSWORD, self::DATABASE);
         self::$instance->query("SET NAMES 'utf8'");
     }
     return self::$instance;
 }
예제 #6
0
 public static function instance()
 {
     if (!isset(self::$instance)) {
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         $pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
         self::$instance = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_SCHEMA, DB_USERNAME, DB_PASSWORD, $pdo_options);
     }
     return self::$instance;
 }
 /**
  * If $name is null then the default connection will be returned.
  *
  * @see Config
  * @param string $name Optional name of a connection
  * @return Connection
  */
 public static function get_connection($name = null)
 {
     $config = Config::instance();
     $name = $name ? $name : $config->get_default_connection();
     if (!isset(self::$connections[$name]) || !self::$connections[$name]->connection) {
         self::$connections[$name] = Connection::instance($config->get_connection($name));
     }
     return self::$connections[$name];
 }
예제 #9
0
 private function __construct()
 {
     try {
         self::$instance = new PDO('mysql:host=localhost;port=3306;dbname=biblioteca;charset=utf8', 'root', 'qwe123');
         self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     } catch (PDOException $e) {
         die("Erro no banco de dados: " . $e->getMessage());
     }
 }
예제 #10
0
 /**
  * Constuctor de la clase haciendo uso del patrón Singletón
  * @return Connection
  */
 public function __construct()
 {
     if (!self::$instance) {
         $this->loadProxyMySql();
         $this->loadProxySoap();
         self::$instance = $this;
     }
     return self::$instance;
 }
예제 #11
0
파일: Index.php 프로젝트: nanjingboy/clown
 public function remove($table, $columns, $options = array())
 {
     $name = $this->getName($columns, $options);
     if ($name === 'PRIMARY') {
         $sql = "ALTER TABLE `{$table}` DROP PRIMARY KEY";
     } else {
         $sql = "ALTER TABLE `{$table}` DROP INDEX `{$name}`";
     }
     return Connection::instance()->execute($sql);
 }
예제 #12
0
 private function __construct()
 {
     try {
         Connection::$instance = new PDO("mysql:host={$this->servername};dbname={$this->dbName}", $this->username, $this->password);
         // set the PDO error mode to exception
         Connection::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         echo "Connected successfully";
     } catch (PDOException $e) {
         echo "Connection failed: " . $e->getMessage();
     }
 }
예제 #13
0
 /**
  * Singleton method that requests a unique instance of the class
  *
  * @return object (PDO)
  * @access public
  */
 public static function getInstance()
 {
     if (!self::$instance instanceof self) {
         try {
             self::$instance = new self();
             self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         } catch (PDOException $e) {
             echo 'Connection failed: ' . $e->getMessage();
         }
     }
     return self::$instance;
 }
예제 #14
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         try {
             self::$instance = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS);
             self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
             self::$instance->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
         } catch (PDOException $e) {
             echo $e->getMessage();
         }
     }
     return self::$instance;
 }
예제 #15
0
파일: Table.php 프로젝트: nanjingboy/clown
 public function remove($table)
 {
     return Connection::instance()->execute("DROP TABLE `{$table}`");
 }
예제 #16
0
 /**
  * Garbage collection.
  *
  * @param int $maxlifetime
  */
 public function cleanup($maxlifetime)
 {
     $db = Connection::instance($this->dbLink);
     $verouderd = time() - $maxlifetime;
     if ($db->query('DELETE FROM ' . $db->quoteIdentifier($this->table) . ' WHERE last_used < ' . $db->quote($verouderd))) {
         return true;
     }
     return false;
 }
예제 #17
0
 /** 
  * @brief	Constructeur de Manager. Récupère la connexion à la base de données
  * @return	Void
  * @note		Ne doit pas être overridé sinon la connexion à la base de données ne sera pas récupérée
  */
 protected function __construct()
 {
     $this->bdd = Connection::instance()->getBdd();
 }
예제 #18
0
파일: User.php 프로젝트: alextsak/Ekpalib
 public function __construct()
 {
     $pdo = Connection::instance();
     $this->db = $pdo->dbConnect();
 }
예제 #19
0
파일: Transaction.php 프로젝트: wukka/db
 public static function instance($name)
 {
     $obj = Connection::instance($name);
     self::add($obj);
     return $obj;
 }
예제 #20
0
파일: Column.php 프로젝트: nanjingboy/clown
 public function remove($table, $column)
 {
     return Connection::instance()->execute("ALTER TABLE `{$table}` DROP `{$column}`");
 }
 private function __destruct()
 {
     self::$instance = null;
 }