Example #1
0
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new DataBase();
     }
     return self::$instance;
 }
 /**
  * Gets an instance of the Database class
  *
  * @static
  * @return Database An instance of the database singleton class.
  */
 public static function getInstance()
 {
     if (empty(self::$instance)) {
         self::$instance = new Database();
     }
     return self::$instance;
 }
Example #3
0
 /**
  *
  * @return DataBase
  */
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #4
0
 /**
  * Método que garantiza que sólo habrá una instancia de esta clase, con los
  * dos métodos anteriores junto con este, se crea un "Singleton Pattern"
  * con lo cual emulamos lo que sería una clase estática (lo que en java
  * hacemos con "public static class blah {}").
  * (Tomado del manual de php:
  *             http://php.net/manual/en/language.oop5.patterns.php)
  */
 public static function getInstance() {
     if (!isset(self::$instance)) {
         $c = __CLASS__;
         $inst = new $c;
         $inst->link = $inst->connect();
         self::$instance = $inst;
     }
     return self::$instance;
 }
Example #5
0
 public static function construct()
 {
     //Si on est en localhost ...
     if ($_SERVER['HTTP_HOST'] == 'localhost') {
         self::$dsn = 'mysql:dbname=gescabmed;host=localhost;charset=UTF8';
         self::$user = '******';
         self::$psw = '';
     } else {
         self::$dsn = 'mysql:dbname=u298100800_gcm;host=mysql.hostinger.fr';
         self::$user = '******';
         self::$psw = 'azerty';
     }
     //On lance la connexion (objet PDO)
     try {
         self::$instance = new PDO(self::$dsn, self::$user, self::$psw);
     } catch (Execption $e) {
         echo "Erreur connexion PDO" . $e->message;
     }
 }
Example #6
0
 private static function _getDb()
 {
     return DataBase::instance(DB_GLOBAL_IP, DB_GLOBAL_PORT, DB_GLOBAL_USER, DB_GLOBAL_PASSWD, DB_GLOBAL_NAME, DB_GLOBAL_LOG);
 }
Example #7
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '../init.inc.php';
$table = $_REQUEST['table'];
$result = array();
if ($table) {
    $db = DataBase::instance(DB_GLOBAL_IP, DB_GLOBAL_PORT, DB_GLOBAL_USER, DB_GLOBAL_PASSWD, DB_GLOBAL_NAME, DB_GLOBAL_LOG);
    $result = $db->excute("select * from yangfan_cmcc");
}
function javaClassName($str = '', $type = 0)
{
    $arr = split('_', $str);
    $tmp = "";
    foreach ($arr as $i) {
        $tmp .= ucwords($i);
    }
    if ($type == 1) {
        $tmp[0] = strtolower($tmp[0]);
    }
    return $tmp;
}
function jdbcType($str = '', $type = 0)
{
    if (substr($str, 0, 3) == 'int') {
        return "INTEGER";
    }
    if (substr($str, 0, 7) == 'varchar') {
        return "VARCHAR";
    }
    if (substr($str, 0, 4) == 'text') {
        return "LONGVARCHAR";