国产精品成人VA在线观看,亚洲日韩在线中文字幕综合,亚洲AV电影天堂男人的天堂,久久人人爽人人爽人人av东京热

News新聞

業(yè)界新聞動(dòng)態(tài)、技術(shù)前沿
Who are we?

您的位置:首頁(yè)      樂(lè)道系統(tǒng)FAQ      php中分頁(yè)及SqlHelper類(lèi)用法實(shí)例

php中分頁(yè)及SqlHelper類(lèi)用法實(shí)例

標(biāo)簽: 發(fā)布日期:2017-01-12 00:00:00 234
【CLI】利用Curl下載文件實(shí)時(shí)進(jìn)度條顯示的實(shí)現(xiàn)

本文實(shí)例講述了php中分頁(yè)及SqlHelper類(lèi)用法。分享給大家供大家參考,具體如下:

文檔目錄結(jié)構(gòu)如下:

SqlHelper.php代碼如下:

<?php
/**
 * Created by JetBrains PhpStorm.
 * User: lee
 * Date: 13-7-26
 * Time: 下午8:30
 * To change this template use File | Settings | File Templates.
 */
class SqlHelper{
  private $mysqli;
  private static $host="localhost";
  private static $user="root";
  private static $pwd="";
  private static $db="world";
  private $sql=false;
  private $result=false;
  function __construct(){
    $this->mysqli=new MySQLi(self::$host,self::$user,self::$pwd,self::$db);
    if($this->mysqli->connect_error){
      die("連接數(shù)據(jù)庫(kù)失?。?".$this->mysql->connect_error);
    }
    $this->mysqli->query("set names utf8");
  }
  function execute_dql_all($sql){
    //執(zhí)行查詢語(yǔ)句
    $arr=array();
    $this->result=$this->mysqli->query($sql) or die ($this->mysql->connect_error);
    //將數(shù)據(jù)轉(zhuǎn)存到$arr數(shù)組中
    while($row=mysqli_fetch_array($this->result,MYSQL_BOTH)){
      $arr[]=$row;
    }
    $this->result->free();
    return $arr;
  }
  function execute_dql_num($sql){
    //執(zhí)行查詢語(yǔ)句
    $arr=array();
    $this->result=$this->mysqli->query($sql) or die ($this->mysql->connect_error);
    //將數(shù)據(jù)轉(zhuǎn)存到$arr數(shù)組中
    while($row=mysqli_fetch_array($this->result,MYSQLI_NUM)){
      $arr[]=$row;
    }
    $this->result->free();
    return $arr;
  }
  function execute_dql_assoc($sql){
    //執(zhí)行查詢語(yǔ)句
    $arr=array();
    $this->result=$this->mysqli->query($sql) or die ($this->mysql->connect_error);
    //將數(shù)據(jù)轉(zhuǎn)存到$arr數(shù)組中
    while($row=mysqli_fetch_array($this->result,MYSQLI_ASSOC)){
      $arr[]=$row;
    }
    $this->result->free();
    return $arr;
  }
  //查詢某表中的記錄數(shù)
  function execute_dql_counts($table,$id="*"){
    $this->sql="select count($id) from $table";
    $this->result=$this->mysqli->query($this->sql);
    $row=mysqli_fetch_all($this->result);
    $this->result->free();
    return $row[0][0];
  }
  function execute_dml($sql){
    //執(zhí)行正刪改
    $this->result=$this->mysqli->query($sql);
    if(!$this->result){
      return -1;//執(zhí)行正刪改失敗
    }else{
      if($this->mysqli->affected_rows>0){
        return 1;//執(zhí)行正刪改成功,影響行數(shù)
      }else{
        return 0;//執(zhí)行正刪改成功,但沒(méi)有影響行數(shù)
      }
    }
  }
}