ThinkPHP5杂技(二)

不要使用数据库查询嵌套

        if (!$listA = Db::name('coin')
            ->field('id,symbol')
            ->where('id', 'IN', logic('Alliance/Alliance')->getSet($this->site['id'], 'coin'))
            ->order('id asc')
            ->select()) {
            $this->error('没有可用币种');
        }

logic Alliance中包含数据查询,导致内部采用了field('id, symbol')条件

 

TP5分页默认是get方式做跳转

想要实现ajax样式,通过事先绑定click事件,然后移除href属性。

$(document).ready(function () {
  $(".pagination > li > a").each(function () {
    $(this).click(function () {
      var href = $(this).attr('href');
      $(this).removeAttr('href');
      $.ajax({
        type: "GET",
        url: href,
        dataType: "html",
        success: function (data) {
          $(".inbox-body").html(data);
        }
      })
    });
  });
posted @ 2017-11-25 13:36  xiaobaicaidage  阅读(146)  评论(0编辑  收藏  举报