本文整理汇总了PHP中static::db方法的典型用法代码示例。如果您正苦于以下问题:PHP static::db方法的具体用法?PHP static::db怎么用?PHP static::db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类static
的用法示例。
在下文中一共展示了static::db方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connect
public static function connect($db)
{
$uri = 'mongodb://something';
$mongo = new MongoClient($uri, ['username' => 'user', 'password' => 'password', 'ssl' => true, 'w' => true]);
static::$db = $mongo->{$db};
static::$connection = $mongo;
static::$isConnected = static::$connection->connected;
}
示例2: set_up
public function set_up($connection_name = null)
{
ActiveRecord\Table::clear_cache();
$config = ActiveRecord\Config::instance();
$this->original_default_connection = $config->get_default_connection();
$this->original_date_class = $config->get_date_class();
if ($connection_name) {
$config->set_default_connection($connection_name);
}
if ($connection_name == 'sqlite' || $config->get_default_connection() == 'sqlite') {
// need to create the db. the adapter specifically does not create it for us.
static::$db = substr(ActiveRecord\Config::instance()->get_connection('sqlite'), 9);
new SQLite3(static::$db);
}
$this->connection_name = $connection_name;
try {
$this->conn = ActiveRecord\ConnectionManager::get_connection($connection_name);
} catch (ActiveRecord\DatabaseException $e) {
$this->mark_test_skipped($connection_name . ' failed to connect. ' . $e->getMessage());
}
$GLOBALS['ACTIVERECORD_LOG'] = false;
$loader = new DatabaseLoader($this->conn);
$loader->reset_table_data();
if (self::$log) {
$GLOBALS['ACTIVERECORD_LOG'] = true;
}
}
示例3: DB
/** @return DB */
public static function DB()
{
if (is_null(static::$db)) {
static::$db = new DB(static::GetConnection(), PREFIX);
}
return static::$db;
}
示例4: init
protected static function init()
{
if (!empty(static::$db)) {
return;
}
static::$db = classSupernova::$db;
}
示例5: getManager
function getManager()
{
if (is_null(static::$db)) {
static::$db = makeDB();
}
return static::$db;
}
示例6: connect
public static function connect()
{
if (!self::$con) {
static::$con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error());
static::$db = mysql_select_db(DB_NAME, self::$con) or die("Failed to connect to mysql:" . mysql_errno());
}
}
示例7: catch
/**
* constructor
* @param mixed param PDO instance,
* or record id (if integer),
* or constraints (if array) but param['pdo'] is PDO instance
*/
function __construct($params = null)
{
try {
if (!static::$db && static::$adapter) {
static::$db = new static::$adapter(static::$db_settings);
}
} catch (Exception $e) {
throw new WaxDbException("Cannot Initialise DB", "Database Configuration Error");
}
$class_name = get_class($this);
if ($class_name != 'WaxModel' && !$this->table) {
$this->table = Inflections::underscore($class_name);
}
$this->define($this->primary_key, $this->primary_type, $this->primary_options);
$this->setup();
$this->set_identifier();
// If a scope is passed into the constructor run a method called scope_[scope]().
if ($params) {
$method = "scope_" . $params;
if (method_exists($this, $method)) {
$this->{$method};
} else {
$res = $this->filter(array($this->primary_key => $params))->first();
$this->row = $res->row;
$this->clear();
}
}
}
示例8: __construct
/**
* Constructor.
*
* @param \wpdb $db
*/
public function __construct(wpdb $db)
{
if (!isset(static::$instance)) {
static::$instance = $this;
static::$db = $db;
}
}
示例9: init
/**
* Main function for initialize this class.
* @param \Slim\Slim
*/
public static function init()
{
date_default_timezone_set(static::config()->timezone);
static::$db = static::config()->db;
static::$user = new \ptejada\uFlex\User();
static::$app = new \Slim\Slim();
static::$mail = new \PHPMailer();
static::$assets = new \Assets();
static::$user->config->database->host = static::config()->db['server'];
static::$user->config->database->user = static::config()->db['username'];
static::$user->config->database->password = static::config()->db['password'];
static::$user->config->database->name = static::config()->db['database_name'];
static::$user->start();
require 'app/config/mail.php';
static::$mail->isSMTP();
static::$mail->Host = $mail['Host'];
static::$mail->SMTPAuth = $mail['SMTPAuth'];
static::$mail->Username = $mail['Username'];
static::$mail->Password = $mail['Password'];
static::$mail->SMTPSecure = $mail['SMTPSecure'];
static::$mail->Port = $mail['Port'];
static::$mail->From = $mail['From'];
static::$mail->FromName = $mail['FromName'];
static::$mail->isHTML(true);
}
示例10: connect
public static function connect()
{
if (is_null(static::$db)) {
static::$db = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
}
return static::$db;
}
示例11: __construct
public function __construct()
{
static::$instance = $this;
if (!isset(static::$db)) {
static::$db = new DatabaseConnect();
}
}
示例12: getInstance
/**
* Returns the *Singleton* instance of this class.
*
* @return Factory the singleton instance.
*/
public static function getInstance()
{
if (null === static::$instance) {
static::$instance = new static();
static::$db = \Xoops::getInstance()->db();
}
return static::$instance;
}
示例13: getDbConnection
/**
* 返回active record使用的数据库连接。
* 默认使用'db'应用组件作为数据库连接。
* 如果你想使用不同的数据库连接的话你可以重写该方法。
* @return ConnectionPool active record使用的数据库连接。
*/
public static function getDbConnection()
{
if (static::$db !== null) {
return static::$db;
} else {
return static::$db = \Sky\Sky::$app->getDb();
}
}
示例14: getDb
/**
* Returns new cmysql class for custom SQL querying, based on current database connection
* @return cMySql
*/
public static function getDb($fresh = false)
{
if ($fresh || !isset(self::$db)) {
static::$db = new MySQL(static::connect());
return static::$db;
}
return static::$db;
}
示例15: getDbConnection
/**
* getDbConnection return current DB connection or create new if not exist
*
* @return type
*/
static function getDbConnection()
{
if (empty(static::$db)) {
$pdo = Service::get('pdo');
static::$db = new \PDO($pdo['dns'], $pdo['user'], $pdo['password']);
}
return static::$db;
}