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