/** * Restituisce un singleton per la connessione al Db * @return \Db */ public static function getInstance() { if (!isset(self::$singleton)) { self::$singleton = new Db(); } return self::$singleton; }
public static function create($key, $secret) { $pdo = Db::singleton(); $pdo->exec("insert into oauth_consumer (consumer_key,consumer_secret,active) values ('" . $key . "','" . $secret . "',1)"); $consumer = new Consumer($pdo->lastInsertId()); return $consumer; }
function __construct() { $this->db = Db::singleton(); $this->id = 0; $this->user = ""; $this->pass = ""; $this->email = ""; }
public function __construct($id = 0) { $this->pdo = Db::singleton(); if ($id != 0) { $this->id = $id; $this->load(); } }
function order_lookup($order_id) { global $statusArray; $pdo = Db::singleton(); $sql = "SELECT * FROM orders where `ID` = '{$order_id}' OR `order_key` = '{$order_id}' LIMIT 1"; $res = $pdo->query($sql); while ($row = $res->fetch()) { return $statusArray[$row['status']]; } return 'No Order Matching that ID was found'; }
function get_user($uid) { if (isset($uid) && !empty($uid)) { $pdo = Db::singleton(); $sql = "SELECT * FROM `user` WHERE `ID`='{$uid}';"; # echo $sql; $res = $pdo->query($sql); while ($row = $res->fetch()) { return $row; } } return null; }
<?php session_start(); include "config.php"; include "pdo.class.php"; include 'Services/Twilio.php'; $pdo = Db::singleton(); $client = new Services_Twilio($accountsid, $authtoken); $room = $_SESSION['room']; $sql = "SELECT * FROM conference where `ID` = '{$room}'"; $res = $pdo->query($sql); $row = $res->fetch(); header('Content-type: text/xml'); echo '<?xml version="1.0" encoding="UTF-8"?>'; ?> <Response> <Dial> <Conference startConferenceOnEnter='false'><?php echo $row['ID']; ?> </Conference> </Dial> </Response>
public function __construct($uploadId) { $this->db = Db::singleton(); $this->load($uploadId); }
/** * db类 使用示例 */ public function dbAction() { // $db_conf = RThink_Config::get('db.test'); $db_conf = array('host' => 'localhost', 'dbname' => 'test', 'username' => 'root', 'password' => ''); $db = Db::singleton($db_conf); $db->getProfiler()->setEnabled(true); $db_profilers[] = $db->getProfiler(); $this->getFrontController()->getRequest()->setParam('db_profilers', $db_profilers); $stmt = $db->query('SELECT * FROM story where id > :id limit 1', array("id" => 0)); $res = $stmt->fetchAll(); }
public function __construct($accept = array()) { $this->db = Db::singleton(); $this->acceptFileTypes = $accept; }