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. 2、join()方法示例:
  8. 代码如下:
  9. $user = new Model('user');
  10. $list = $user->join('RIGHT JOIN user_profile ON user_stats.id = user_profile.typeid' );
  11. 3、table()方法示例:
  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();

最新文章

  1. Vijos1404遭遇战[最短路建模]
  2. CnBlog客户端Windows Live Write安装方法
  3. expdp和impdp的用法
  4. cf A. Inna and Pink Pony(思维题)
  5. 采用jsp用表格的形式显示
  6. (六)backbone - API学习 - Backbone路由
  7. 【转载】安装和使用花生壳(linux)
  8. YARN的capacity调度器主要配置分析
  9. dev gridcontrol 绑定int型及日期型的列默认当值为0时显示空白及格式化日期显示方式
  10. find指令参数
  11. [译][待续]Chap1.Using neural nets to recognize handwritten digits
  12. android 动态string
  13. getcomputedstyle()获取border像素差异问题
  14. windows 命令直接搜索局域网计算机的ip
  15. SpringCloud使用Prometheus监控(基于Eureka)
  16. FTP:500 OOPS: failed to open vsftpd log file:/var/log/vsftpd.log
  17. yolov3实践(二)
  18. SpringBoot处理静态资源的两种方式
  19. Js基础知识1-数组操作全解
  20. web前端设计规范

热门文章

  1. Python_散点图与折线图绘制
  2. opencv实践::对象计数
  3. go-go协程
  4. 14.Linux压缩/打包
  5. Unity - HasExitTime用法
  6. ssd原理及代码实现详解
  7. ExtJs 扩展类CheckColumn修改源码,支持按条件禁用启用下拉框功能
  8. MacOs mysql 安装
  9. 详细解读 Spring AOP 面向切面编程(二)
  10. Linux命令比较文件内容