zoukankan      html  css  js  c++  java
  • thinkphp两表,多表联合查询及分页的连贯操作写法

    1. ThinkPHP中关联查询(即多表联合查询)可以使用 table() 方法或和join方法,具体使用如下例所示:
    2. 1、原生查询示例:
    3. 代码如下:
    4. $Model = new Model();
    5.  $sql = 'select a.id,a.title,b.content from think_test1 as a, think_test2 as b where a.id=b.id '.$map.' order by a.id '.$sort.' limit '.$p->firstRow.','.$p->listRows;
    6.  $voList = $Model->query($sql);
    7. 2join()方法示例:
    8. 代码如下:
    9. $user = new Model('user');
    10.  $list = $user->join('RIGHT JOIN user_profile ON user_stats.id = user_profile.typeid' );
    11. 3table()方法示例:
    12. 代码如下:
    13. $list = $user->table('user_status stats, user_profile profile')->where('stats.id = profile.typeid')->field('stats.id as id, stats.display as display, profile.title as title,profile.content as content')->order('stats.id desc' )->select();

    $data=$manage->table('template, app')->where('template.appid = app.appid')->field('template.teptype, app.appname')->order('template.id asc')->limit($Page->firstRow.','.$Page->listRows)->select();

    A buddhist programmer.
  • 相关阅读:
    使用Link Shell Extension方便的创建同步文件
    DOM案例【3】密码强度检查案例
    DOM案例【2】注册文本倒计时
    DOM案例【1】文本时钟
    HTML5 and CSS【01】Font
    常用单词
    CSS基础【01】类和ID选择器的区别
    【03】Html重点
    【02】Html(如鹏)
    C#MD5计算代码
  • 原文地址:https://www.cnblogs.com/wszz/p/7883822.html
Copyright © 2011-2022 走看看