1、table()函数
thinkphp中提供了一个table()函数,具体用法参考以下语句:
$list=$Demo->table('think_blog blog,think_type type')->where('blog.typeid=type.id')->field('blog.id as id,blog.title,blog.content,type.typename as type')->order('blog.id desc' )->limit(5)->select();
echo $Demo->getLastSql(); //打印一下SQL语句,查看一下
2、join()函数
看一下代码:
$Demo = M('artist');
$Demo->join('RIGHT JOIN think_work ON think_artist.id = think_work.artist_id' );
//可以使用INNER JOIN 或者 LEFT JOIN 这里一定要注意表名的前缀!
echo $Demo->getLastSql(); //打印一下SQL语句,查看一下
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。