<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 數據庫 數據庫源目錄 `lib/Db`,定義需要連接的數據庫。 數據源示例: ```php /** * Fend Framework * [Gimoo!] (C)2006-2009 Gimoo Inc. (http://fend.gimoo.net) * * 同學主庫 * * @Package GimooFend * @Author Gimoo <gimoohr@gmail.com> * @version $Id$ **/ class Db_Shop extends Fend_Db_Mysqli { static $in=array(); public static function Factory($r) { // 如果未配置讀寫分離,則默認只連如寫庫 !isset($GLOBALS['_db_shop'][$r]) && $r='w'; // 校驗是否存在實例 !isset(self::$in[$r]) && self::$in[$r]=new self($r); // 返回已經連入的實例 return self::$in[$r]; } //初始化Mysql對象并進行連接服務器嘗試 public function __construct($r) { $this->_cfg=$this->db_shop[$r]; if(!isset($this->_cfg['port'])){ $this->_cfg['port']='3306'; } if(!isset($this->_cfg['lang'])){ $this->_cfg['lang']='utf8'; } $this->_db=new mysqli($this->_cfg['host'],$this->_cfg['user'],$this->_cfg['pwd'],$this->_cfg['name'],$this->_cfg['port']); if (mysqli_connect_errno()) { self::showMsg("Connect failed: ". mysqli_connect_error()); } $this->_db->query("SET character_set_connection={$this->_cfg['lang']},character_set_results={$this->_cfg['lang']},character_set_client=binary,sql_mode='';"); } //清理DB連接 public static function clean() { //關閉庫連接 foreach(self::$in as $obj ){ $obj->_db->close(); } //銷毀變量 self::$in=array(); } // 測試用的 public function state() { print_R(self::$in); // print_R($this->_db->stat()); } } ``` 基礎方法: ```php /** * DB Read 基礎類 * @Author Wanglele <wanglelecc@gmail.com> * @version 2.0.1 */ abstract class Db_Read extends Db_Init { /** * 表名 * @var string */ protected $table = ''; /** * Db 名稱 * @var string */ protected $dbName = 'Db_Shop'; /** * 獲取對象 * @return $this */ public static function Factory() { return new static; } /** * 構造方法 */ public function __construct() { $this->boot(); } /** * 初始化操作 */ public function boot() { } /** * 獲取表名 * @return string */ public function table() { return $this->table; } /** * 獲取 Db 對象 * @return mixed */ public function db() { return $this->dbName::Factory('r'); } /** * 獲取信息 * @param int $id 欄目 * @return array 基本信息 * */ public function get($id, $e = '*') { !$e && $e = "*"; $rs = $this->db()->get("SELECT {$e} FROM {$this->table} WHERE id={$id}"); return !empty($rs) ? $rs : []; } /** * 獲取多組信息 * @param int $id * @param string $e * @param $index * @return array */ public function gets($id, $e = '*', $index = '') { !$e && $e = "*"; if (is_array($id)) { $id = implode(',', $id); } // 連接DB $db = $this->db(); $item = []; $q = $db->query("SELECT {$e} FROM {$this->table} WHERE id in ({$id})"); while ($rs = $db->fetch($q)) { if ($index) { $item[$rs[$index]] = $rs; } else { $item[] = $rs; } } return !empty($item) ? $item : []; } /** * 根據條件獲取信息 * @return array */ public function getOne() { $rs = $this->db()->get("SELECT {$this->_field} FROM {$this->table} {$this->_where} {$this->_order} LIMIT 0, 1"); // 重置查詢條件 parent::reset(); return !empty($rs) ? $rs : []; } /** * 獲取查詢 * @param $sql * @return array */ public function getQuery($sql) { $rs = $this->db()->get($sql); return !empty($rs) ? $rs : []; } /** * 查詢一組數據 * @param int $psize 每頁顯示條目 * @param int $skip 跳過多少條 * @return array **/ public function getData($psize = 10, $skip = 0) { $item = []; // 連接DB $db = $this->db(); $q = $db->query("SELECT {$this->_field} FROM {$this->table} {$this->_where} {$this->_order} LIMIT {$skip},{$psize}"); while ($rs = $db->fetch($q)) { $item[] = $rs; } // 重置查詢條件 self::reset(); return $item; } /** * 列表查詢 * @param int $psize 每頁顯示條目 * @param int $skip 跳過多少條 * @return array **/ public function getList($psize = 10, $skip = 0) { $item = ['psize' => $psize, 'skip' => $skip, 'total' => 0, 'list' => []]; // 連接DB $db = $this->db(); // 查詢總數 $item['total'] = (int)$db->get("SELECT COUNT(*) FROM {$this->table} {$this->_where}", 1); // 查詢列表 if ($item['total'] > 0) { $q = $db->query("SELECT {$this->_field} FROM {$this->table} {$this->_where} {$this->_order} LIMIT {$skip},{$psize}"); while ($rs = $db->fetch($q)) { $item['list'][] = $rs; } } // 重置查詢條件 parent::reset(); return $item; } /** * 獲取數據 * @return array **/ public function getAll() { // 連接DB $db = $this->db(); // 返回數據 $items = []; $q = $db->query("SELECT {$this->_field} FROM {$this->table} {$this->_where} {$this->_order}"); while ($rs = $db->fetch($q)) { $items[] = $rs; } // 重置查詢條件 parent::reset(); return $items; } /** * 根據 sql 獲取全部數據 * @param string $sql * @return array **/ public function getAllQuery($sql) { // 連接DB $db = $this->db(); // 返回數據 $items = []; $q = $db->query($sql); while ($rs = $db->fetch($q)) { $items[] = $rs; } return $items; } /** * 查詢總數 * @return integer */ public function getTotal() { // 查詢總數 return (int)$this->db()->get("SELECT COUNT(*) FROM {$this->table} {$this->_where}", 1); } /** * 獲取完整圖片 URL * @param $img * @return string */ public function getImage($img) { return Misc_Image::getUrl($img); } /** * 獲取 CC 視頻完整 URL * @param $vurl * @param int $quality * @return string */ public function getVideo($vurl, $quality = 0) { return Misc_Image::getVideo($vurl, $quality); } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看