本文整理汇总了PHP中DataBase::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP DataBase::instance方法的具体用法?PHP DataBase::instance怎么用?PHP DataBase::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataBase
的用法示例。
在下文中一共展示了DataBase::instance方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
public static function getInstance()
{
if (!self::$instance) {
self::$instance = new DataBase();
}
return self::$instance;
}
示例2: getInstance
/**
* 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;
}
示例3: getInstance
/**
*
* @return DataBase
*/
public static function getInstance()
{
if (self::$instance == null) {
self::$instance = new self();
}
return self::$instance;
}
示例4: getInstance
/**
* 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;
}
示例5: construct
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 = 'root';
self::$psw = '';
} else {
self::$dsn = 'mysql:dbname=u298100800_gcm;host=mysql.hostinger.fr';
self::$user = 'u298100800_root';
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;
}
}
示例6: _getDb
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);
}
示例7: array
<?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";