本文整理汇总了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;
}