本文整理匯總了PHP中static::pdo方法的典型用法代碼示例。如果您正苦於以下問題:PHP static::pdo方法的具體用法?PHP static::pdo怎麽用?PHP static::pdo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類static
的用法示例。
在下文中一共展示了static::pdo方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getPdoInstance
/**
* PDO singletone
*
* @return PDO
*/
static function getPdoInstance() : \PDO
{
if (static::$pdo === null) {
static::$pdo = new \PDO(self::DB_INFO, self::DB_USER, self::DB_PASSWORD, [\PDO::MYSQL_ATTR_LOCAL_INFILE => true]);
}
return static::$pdo;
}
示例2: resolveConnection
public static function resolveConnection($connection = null)
{
if (is_null(static::$pdo)) {
static::$pdo = m::mock('TestPDO')->makePartial();
}
return new SpatialConnection(static::$pdo);
}
示例3: __construct
private function __construct()
{
try {
static::$pdo = new PDO('mysql:host=localhost;dbname=underline', 'root', 'root', array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
} catch (PDOException $e) {
echo $e->getMessage();
}
}
示例4: getDb
/**
* Get pdo instance
* @return PDO
*/
public static function getDb()
{
if (empty(static::$pdo)) {
static::$pdo = Sf::createObject('db')->getDb();
static::$pdo->exec("set names 'utf8'");
}
return static::$pdo;
}
示例5: PDO
public static function &connection()
{
if (null === static::$pdo) {
static::$pdo = new PDO(static::$connection['dsn'], static::$connection['username'], static::$connection['password'], static::$connection['options']);
Event::triggerOnce('core.sql.connect');
}
return static::$pdo;
}
示例6: initPdo
private function initPdo()
{
$connectionName = 'default';
if (isset(static::$connectionName)) {
$connectionName = static::$connectionName;
}
static::$pdo = PdoSupport::$pdoProvider->getPdo($connectionName);
}
示例7: getInterface
public function getInterface()
{
if (is_null(static::$pdo)) {
static::$pdo = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';', DB_USER, DB_PASSWORD);
$now = new DateTime();
$now->setTimeZone(new DateTimeZone(TIME_ZONE));
static::$pdo->exec("SET time_zone='" . $now->format('P') . "'");
}
return static::$pdo;
}
示例8: get
/**
* Get the active database object
* Create it if needed
*
* @return \Kofradia\DB
*/
public static function get()
{
if (!isset(static::$pdo)) {
$obj = "\\Kofradia\\DB\\PDO";
static::$pdo = new $obj(sprintf("mysql:host=%s;dbname=%s;charset=utf8", DBHOST, DBNAME), DBUSER, DBPASS);
static::$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
static::$pdo->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
}
return static::$pdo;
}
示例9: tearDownAfterClass
public static function tearDownAfterClass()
{
static::$driver = null;
static::$pdo = null;
foreach (static::$tempFiles as $file) {
if (is_file($file)) {
unlink($file);
}
}
parent::tearDownAfterClass();
}
示例10: PDO
static function PDO()
{
if (!static::$pdo) {
try {
static::$pdo = new \PDO("mysql:host=localhost;dbname=" . getenv('MYSQL_DB'), getenv('MYSQL_USER'), getenv('MYSQL_PASSWORD'));
} catch (Exception $e) {
die('Erreur : ' . $e->getMessage());
}
}
return static::$pdo;
}
示例11: setPDO
public static function setPDO(PDO $pdo)
{
static::$pdo = $pdo;
}
示例12: free
public static function free()
{
static::$pdo = null;
static::$no = null;
}
示例13: reset
public static function reset($sql = '')
{
// 保存最後的數據庫操作語句
if ($sql) {
static::$lastSql = $sql;
}
static::$pdo = '';
static::$pk = array('key' => 'id', 'value' => '');
static::$table = '';
// 默認是 AR 的調用模式, 獲取當前 AR 類名,即為表名
static::$where = '';
static::$orWhere = '';
static::$sqlSelect = array('fields' => '', 'group' => '', 'order' => '', 'limit' => '');
static::$saveData = [];
static::$bindValue = [];
}
示例14: connect
public static function connect($dsn, $host, $password)
{
static::$pdo = new PDO($dsn, $host, $password, array(PDO::ATTR_PERSISTENT => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
}