久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

thinkPHP分頁功能實(shí)例詳解

這篇文章主要介紹了thinkPHP分頁功能,結(jié)合完整實(shí)例形式分析了thinkPHP基于商品模型實(shí)現(xiàn)分頁功能的相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了thinkPHP分頁功能。分享給大家供大家參考,具體如下:

interface ServiceInterFace:

<?php
/**
 * InterFaceService
 * @author yhd
 */
namespace Red;
interface ServiceInterFace {
  /**
   * 實(shí)例化當(dāng)前類
   */
  public static function getInstance();
}

StaticService 靜態(tài)服務(wù)類:

<?php
/**
 * 靜態(tài)服務(wù)類
 * StaticService
 * @author yhd
 */
namespace Red;
class StaticService{
  protected static $data;
  /**
   * 設(shè)置靜態(tài)數(shù)據(jù)
   * @param string $key key
   * @param mixed $data data
   * @return mixed
   */
  public static function setData($key,$data){
    self::$data[$key] = $data;
    return self::$data[$key];
  }
  /**
   * 通過引用使用靜態(tài)數(shù)據(jù)
   * @param string $key key
   * @return mixed
   */
  public static function & getData($key){
    if(!isset(self::$data[$key])){
      self::$data[$key] = null;
    }
    return self::$data[$key];
  }
  /**
   * 緩存實(shí)例化過的對(duì)象
   * @param string $name 類名
   * @return 對(duì)象
   */
  public static function getInstance($name){
    $key = 'service_@_'.$name;
    $model = &self::getData($key);
    if($model === null){
      $model = new $name();
    }
    return $model;
  }
  /**
   * html轉(zhuǎn)義過濾
   * @param mixed $input 輸入
   * @return mixed
   */
  public static function htmlFilter($input){
    if(is_array($input)) {
      foreach($input as & $row) {
        $row = self::htmlFilter($row);
      }
    } else {
      if(!get_magic_quotes_gpc()) {
        $input = addslashes($input);
      }
      $input = htmlspecialchars($input);
    }
    return $input;
  }
}

abstract AbProduct  抽象商品管理類:

<?php
/**
* 抽象商品管理類
* AbProduct.class.php
* @lastmodify 2015-8-17
* @author yhd
*/
namespace Red\Product;
abstract class AbProduct{
  public $errorNum;
  /*
  *返回錯(cuò)誤信息
  *@param $errorNum 錯(cuò)誤代碼
  */
  public function GetStatus(){
    $errorNum = $this->errorNum;
    switch($errorNum){
        case 0:
            $data['status'] = 0;
            $data['message'] = '收藏成功';
            break;
        case 1:
            $data['status'] = 1;
            $data['message'] = '收藏失敗';
            break;
        case 2:
            $data['status'] = 2;
            $data['message'] = '已收藏';
            break;
        case 3:
            $data['status'] = 3;
            $data['message'] = '未登陸';
            break;
        case 4:
            $data['status'] = 4;
            $data['message'] = '缺少參數(shù)';
            break;
        default:
            $data['status'] = 200;
            $data['message'] = '未知錯(cuò)誤';
    }
    return $data;
  }

MemberModel 會(huì)員模型:

<?php
/**
* 會(huì)員模型
* MemberModel.class.php
* @copyright (C) 2014-2015 red
* @license http://www.red.com/
* @lastmodify 2015-8-17
* @author yhd
*/
namespace Red\Passport\Models;
use Think\Model;
use Red\ServiceInterFace;
use Red\StaticService;
class MemberModel extends Model implements ServiceInterFace{
  protected $userId;
  protected $error;
  protected function _initialize(){
    $this->userId = getUserInfo(0);
  }
   /**
   * 實(shí)例化本類
   * @return MemberModel
   */
  public static function getInstance() {
    return StaticService::getInstance(__CLASS__);
  }
   /**
   *  獲取登錄用戶信息
   * @param string  $data 查詢條件
   * @return array
   */
  public function getUser($data = '') {
    if(empty($data)){
      return $this->where("id=".$this->userId)->find();
    }else{
      return $this->field($data)->where("id=".$this->userId)->find();
    }
  }
  /**
   * 修改用戶信息
   * @param array $data
   * @param array $where 查詢條件
   */
  public function editUserInfo($data, $where = '') {
    if( $this->_before_check($data) === false ){
      return $this->error['msg'];
    }
    if(!empty($where) && is_array($where)){
      $condition[ $where[0] ] = array('eq', $where[1]);
      return $this->where($condition)->save($data);
    }
    return $this->where("id=".$this->userId)->save($data);
  }
  /**
   * 獲取用戶信息
   * @param string $data 用戶名
   * return array()
   */
  public function checkUserInfo($str, $field = ''){
    //注冊(cè)類型
    $info = CheckType($str);
    $condition[$info] = array('eq',$str);
    if(!empty($field)){
      return $this->field($field)->where($condition)->find();
    }
    return $this->where($condition)->find();
  }
  /**
   * 獲取用戶信息
   * @param array $data 用戶名
   * return array()
   */
  public function getAccount($data){
    //注冊(cè)類型
    $info = CheckType($data);
    $condition['id'] = array('eq',$this->userId);
    $condition[$info] = array('eq',$data);
    return $this->where($condition)->find();
  }
  /**
   * 修改用戶密碼
   * @param array $data['id']用戶ID
   * @param $data['passWord']用戶密碼
   * return true or false
   */
  public function upUserPassById($data){
    $condition['id'] = array('eq',$data['id']);
    $status = $this->where($condition)->save(array("password"=>md5($data['password'])));
    if($status){
        return TRUE;
    }else {
        return FALSE;
    }
  }
  /**
   * 校驗(yàn)用戶的賬號(hào)或者密碼是否正確
   * @param $data['username'] 用戶名
   * @param $data['password'] 密碼
   * return true or false
   */
  public function checkUserPasswd($data= array()){
      $type = CheckType($data['username']);
      $condition[$type] = array('eq',$data['username']);
      $condition['password'] = array('eq',md5($data['password']));
       return $this->where($condition)->find();
  }
  /**
   * 網(wǎng)頁登錄校驗(yàn)token
   * @param token string
   * return bool
   */
  public function checkToken($token){
      return $this->autoCheckToken($token);
  }
  /**
   * 后臺(tái)封號(hào)/解封
   * param int $user_id
   */
  public function changeStatus($data){
    if($this->save($data)){
      return true;
    }else{
      return false;
    }
  }
  protected function _before_check(&$data){
    if(isset($data['username']) && empty($data['username'])){
      $this->error['msg'] = '請(qǐng)輸入用戶名';
      return false;
    }
    if(isset($data['nickname']) && empty($data['nickname'])){
      $this->error['msg'] = '請(qǐng)輸入昵稱';
      return false;
    }
    if(isset($data['realname']) && empty($data['realname'])){
      $this->error['msg'] = '請(qǐng)輸入真名';
      return false;
    }
    if(isset($data['email']) && empty($data['email'])){
      $this->error['msg'] = '請(qǐng)輸入郵箱';
      return false;
    }
    if(isset($data['mobile']) && empty($data['mobile'])){
      $this->error['msg'] = '請(qǐng)輸入手機(jī)號(hào)碼';
      return false;
    }
    if(isset($data['password']) && empty($data['password'])){
      $this->error['msg'] = '請(qǐng)輸入密碼';
      return false;
    }
    if(isset($data['headimg']) && empty($data['headimg'])){
      $this->error['msg'] = '請(qǐng)上傳頭像';
      return false;
    }
    return true;
  }
}

【網(wǎng)站聲明】本站除付費(fèi)源碼經(jīng)過測(cè)試外,其他素材未做測(cè)試,不保證完整性,網(wǎng)站上部分源碼僅限學(xué)習(xí)交流,請(qǐng)勿用于商業(yè)用途。如損害你的權(quán)益請(qǐng)聯(lián)系客服QQ:2655101040 給予處理,謝謝支持。

相關(guān)文檔推薦

數(shù)字條自帶a鏈接標(biāo)簽代碼和選中效果標(biāo)簽 數(shù)字帶class名稱為 page-num ,當(dāng)前頁自帶 page-num-current 樣式 !-- 分頁 --{pboot:if({page:rows}0)} div class=pagebar div class=pagination a class=page-item page-link hid
適用范圍:分頁條標(biāo)簽適用所有執(zhí)行了分頁的頁面 標(biāo)簽作用:用于輸出分頁代碼 來源:html5模板網(wǎng) html5code.net 1、分頁條標(biāo)簽 {page:bar} 系統(tǒng)內(nèi)置的完整分頁條 {page:current} 當(dāng)前頁碼 {page
下面小編就為大家分享一篇ThinkPHP整合datatables實(shí)現(xiàn)服務(wù)端分頁的示例代碼,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
下面小編就為大家分享一篇thinkphp3.2.0 setInc方法 源碼全面解析,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
這篇文章主要介紹了tp5(thinkPHP5)操作mongoDB數(shù)據(jù)庫的方法,結(jié)合實(shí)例形式簡(jiǎn)單分析了mongoDB數(shù)據(jù)庫及thinkPHP5連接、查詢MongoDB數(shù)據(jù)庫的基本操作技巧,需要的朋友可以參考下
thinkphp官網(wǎng)在去年的時(shí)候發(fā)布了tp的顛覆版本thinkphp5,tp5確實(shí)比之前的版本好用了很多,那么下面這篇文章就來給大家介紹關(guān)于在云虛擬主機(jī)部署thinkphp5項(xiàng)目的相關(guān)資料,需要的朋友可以
主站蜘蛛池模板: 亚洲三级av | 粉嫩av | 国产精品久久久久9999鸭 | 伊色综合久久之综合久久 | 亚洲视频一区二区三区 | 精品久久av | 色播av | 免费成人毛片 | 91精品国产91久久久久久最新 | 欧美日日 | 精品啪啪 | 91pao对白在线播放 | 国产一区二区三区四区 | 国产三区视频在线观看 | 亚洲欧洲成人av每日更新 | 国产一区二区三区四区三区四 | 99精品亚洲国产精品久久不卡 | 免费av手机在线观看 | 拍拍无遮挡人做人爱视频免费观看 | 久久精品亚洲欧美日韩精品中文字幕 | 亚洲精品综合一区二区 | 亚洲免费在线视频 | 涩涩鲁亚洲精品一区二区 | 欧美性大战久久久久久久蜜臀 | 日韩国产中文字幕 | 亚洲高清视频在线观看 | 日本超碰 | 日韩电影中文字幕在线观看 | 精品久久久久久亚洲国产800 | 91爱爱·com | 国产亚洲一区二区三区在线 | 在线一区二区三区 | 91在线精品视频 | 国产成人精品免高潮在线观看 | 婷婷精品 | 岛国一区 | 亚洲在线免费观看 | 欧美白人做受xxxx视频 | 亚洲成人一区二区 | 欧美日本韩国一区二区 | 97精品视频在线 |