在thinkphp中如何实现多表查询
来源:原创
时间:2015-08-25
作者:脚本小站
分类:PHP
多表查询经常使用到,但如何在thinkphp中实现多表查询呢,其实有三种方法。
// 1、原生查询示例: $Model = new Model(); $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; $voList = $Model->query($sql); // 2、join()方法示例: $user = new Model('user'); $list = $user->join('RIGHT JOIN user_profile ON user_stats.id = user_profile.typeid' ); // 3、table()方法示例: $list = $user->table('user1 a, user2 b')->where('a.id = b.id') ->field('name,sex')->order('id desc' )->select();
- php边运行边输出ob_end_clean() flush();
- php统计文本行数 count(file('text.txt'));
- php反向ajax技术Comet
- thinkphp3.2局部不缓存的静态缓存
- phpExcel php导入xls文件
- Warning: File upload error - unable to create a temporary fi
- ueditor后台处理函数集合 for ThinkPHP-实用版
- php无法输出16进制,但可以进行与运算
- ueditor抓取远程图片结合ThinkPHP与阿里云OSS
- php获取当前页面URL $_SERVER['REQUEST_URI']