ThinkPHP中关联查询(即多表联合查询)可以使用 table() 方法或和join方法,具体使用如下例所示:
1、原生查询示例:
代码如下:
firstRow.','.$p->listRows;
$voList = $Model->query($sql);
2、join()方法示例:
代码如下:
join('RIGHT JOIN user_profile ON user_stats.id = user_profile.typeid' );
3、table()方法示例:
代码如下:
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();
更多关于thinkPHP相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》及《PHP模板技术总结》。
希望本文所述对大家基于ThinkPHP框架的PHP程序设计有所帮助。
总结
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。