本文整理匯總了PHP中Db::instance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Db::instance方法的具體用法?PHP Db::instance怎麽用?PHP Db::instance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Db
的用法示例。
在下文中一共展示了Db::instance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: get
public static function get()
{
if (self::$instance == null) {
self::$instance = new self();
}
return self::$instance;
}
示例2: save
public function save()
{
$db = Db::instance();
// map database fields to class properties; omit id and dateCreated
$db_properties = array('email' => $this->email, 'name' => $this->name);
$db->store($this, __CLASS__, self::DB_TABLE, $db_properties);
}
示例3: getDbInstance
public static function getDbInstance()
{
if (!isset(self::$instance)) {
self::$instance = new Db();
}
return self::$instance;
}
示例4: getInstance
public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new self(['database_type' => 'mysql', 'database_name' => 'notificador', 'server' => 'localhost', 'username' => 'root', 'password' => '', 'charset' => 'utf8']);
}
return self::$instance;
}
示例5: singleton
public static function singleton()
{
if (self::$instance == false) {
self::$instance = new parent(Config::host, Config::username, Config::pass, Config::dbname);
}
return self::$instance;
}
示例6: getInstance
public static function getInstance()
{
if (!self::$instance) {
self::$instance = new Db();
}
return self::$instance;
}
示例7: save
public function save()
{
$db = Db::instance();
// map database fields to class properties; omit id and dateCreated
$db_properties = array('description' => $this->description, 'group' => $this->group, 'css_class' => $this->cssClass, 'diffable' => $this->diffable, 'hidden' => $this->hidden, 'contribution' => $this->contribution);
$db->store($this, __CLASS__, self::DB_TABLE, $db_properties);
}
示例8: getInstance
public static function getInstance()
{
if (Db::$instance == null) {
Db::$instance = new Db();
}
return Db::$instance;
}
示例9: getInstance
/**
* Singleton
*/
public static function getInstance()
{
if (null === self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
示例10: getInstance
public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
}
return self::$instance;
}
示例11: getInstance
public static function getInstance()
{
if (!self::$instance) {
self::$instance = new PDO('mysql:host=' . _DB_HOST_ . ';dbname=' . _DB_NAME_, _DB_USER_, _DB_PASS_, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true));
}
return self::$instance;
}
示例12: save
public function save()
{
$db = Db::instance();
// map database fields to class properties; omit id and dateCreated
$db_properties = array('user_id' => $this->userID, 'title' => $this->title, 'slug' => $this->slug);
$db->store($this, __CLASS__, self::DB_TABLE, $db_properties);
}
示例13: getDBInstance
public static function getDBInstance()
{
if (self::$instance == null) {
self::$instance = self::initiatePDOObject();
}
return self::$instance;
}
示例14: getInstance
static function getInstance()
{
if (is_null(self::$instance)) {
self::$instance = self::buildInstance();
}
return self::$instance;
}
示例15: getInstance
public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new Db(_DB_SERVER_NAME_, _DB_USER_NAME_, _DB_PASSWORD_, _DB_NAME_);
}
return self::$instance;
}