예제 #1
0
파일: pdo.php 프로젝트: Umz/Simple-PDO
 public static function getInstance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new SimplePDO();
     }
     return self::$_instance;
 }
예제 #2
0
 /**
     获取一个单例对象
 */
 static function &instance()
 {
     if (!self::$pdo instanceof PDO) {
         self::$pdo = new SimplePDO();
     }
     return self::$pdo;
 }
예제 #3
0
 public function this_browser_percent()
 {
     $database = SimplePDO::getInstance();
     // count all requests
     $database->query("SELECT * FROM `requests`");
     $database->execute();
     $total = $database->rowCount();
     // count all requests with current ua string
     $database->query("SELECT * FROM `requests` WHERE `browser_ua` = :browser_ua");
     $database->bind(':browser_ua', $this->browser_ua);
     $database->execute();
     $this_browser = $database->rowCount();
     // return this browser usage in percent
     return $this_browser / $total * 100;
 }
예제 #4
0
 function getAll()
 {
     return SimplePDO::instance()->doQuery("select * from `{this->table}`");
 }
예제 #5
0
파일: Model.php 프로젝트: 2guotou/SimplePDO
 /**
  */
 function saveOne($id, $update)
 {
     $update['update_time'] = date('Y-m-d H:i:s');
     return SimplePDO::instance()->doUpdate($this->table, $update, "id=?", [$id]);
 }