public static function getInstance() { if (!isset(self::$_instance)) { self::$_instance = new SimplePDO(); } return self::$_instance; }
/** 获取一个单例对象 */ static function &instance() { if (!self::$pdo instanceof PDO) { self::$pdo = new SimplePDO(); } return self::$pdo; }
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; }
function getAll() { return SimplePDO::instance()->doQuery("select * from `{this->table}`"); }
/** */ function saveOne($id, $update) { $update['update_time'] = date('Y-m-d H:i:s'); return SimplePDO::instance()->doUpdate($this->table, $update, "id=?", [$id]); }