无为清净楼资源网 Design By www.qnjia.com

本文实例讲述了thinkPHP分页功能。分享给大家供大家参考,具体如下:

interface ServiceInterFace:

<"htmlcode">
<"htmlcode">
<"htmlcode">
<"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 = ''){
    //注册类型
    $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){
    //注册类型
    $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;
    }
  }
  /**
   * 校验用户的账号或者密码是否正确
   * @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();
  }
  /**
   * 网页登录校验token
   * @param token string
   * return bool
   */
  public function checkToken($token){
      return $this->autoCheckToken($token);
  }
  /**
   * 后台封号/解封
   * 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'] = '请输入用户名';
      return false;
    }
    if(isset($data['nickname']) && empty($data['nickname'])){
      $this->error['msg'] = '请输入昵称';
      return false;
    }
    if(isset($data['realname']) && empty($data['realname'])){
      $this->error['msg'] = '请输入真名';
      return false;
    }
    if(isset($data['email']) && empty($data['email'])){
      $this->error['msg'] = '请输入邮箱';
      return false;
    }
    if(isset($data['mobile']) && empty($data['mobile'])){
      $this->error['msg'] = '请输入手机号码';
      return false;
    }
    if(isset($data['password']) && empty($data['password'])){
      $this->error['msg'] = '请输入密码';
      return false;
    }
    if(isset($data['headimg']) && empty($data['headimg'])){
      $this->error['msg'] = '请上传头像';
      return false;
    }
    return true;
  }
}

ProductModel 商品模型:

<"htmlcode">
<"htmlcode">
<"pages"><a href="' . str_replace('{page}', $page - 1 <= 0 " rel="external nofollow" title="上一页" class="page_start">上一页</a>';
  if ($page > 4 && $page <= $total - 4) {
    $mini = $page - 3;
    $maxi = $page + 2;
  } elseif ($page <= 4) {
    $mini = 2;
    $maxi = $total - 2 < 7 "page-num" href="' . str_replace('{page}', $i, $url) . '" rel="external nofollow" >' . $i . '</a>';
    } else {
      $pages .= '<span class="page_cur">' . $i . '</span>';
    }
    if ($maxi && $i >= $maxi) {
      $i = $total - 2;
      $maxi = 0;
    }
    if (($i == 2 or $total - 2 == $i) && $total > 10) {
      $pages .= '';
    }
    if ($mini && $i >= 2) {
      $i = $mini;
      $mini = 0;
    }
  }
  $pages .= '<a href="' . str_replace('{page}', $page + 1 >= $total " rel="external nofollow" title="下一页" class="page_next">下一页</a><span class="pageOp"><span class="sum">共' . $totalcount .
      '条 </span><input type="text" class="pages_inp" id="pageno" value="' . $page . '" onkeydown="if(event.keyCode==13 &amp;&amp; this.value) {window.location.href=\'' . $url . '\'.replace(/\{page\}/, this.value);return false;}"><span class="page-sum">/ ' .
      $total . '页 </span><input type="button" class="pages_btn" value="GO" onclick="if(document.getElementById(\'pageno\').value>0)window.location.href=\'' . $url . '\'.replace(/\{page\}/, document.getElementById(\'pageno\').value);"></span></div>';
  return $pages;
}

更多关于thinkPHP相关内容感兴趣的读者可查看本站专题:《ThinkPHP入门教程》、《thinkPHP模板操作技巧总结》、《ThinkPHP常用方法总结》、《codeigniter入门教程》、《CI(CodeIgniter)框架进阶教程》、《Zend FrameWork框架入门教程》及《PHP模板技术总结》。

希望本文所述对大家基于ThinkPHP框架的PHP程序设计有所帮助。

标签:
thinkPHP,分页

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com

稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!

昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。

这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。

而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?