php框架

 首页 > php框架 > ThinkPHP > THINKPHP 中关联查询 - Thinkphp

THINKPHP 中关联查询 - Thinkphp

分享到:
【字体:
导读:
          THINKPHP 中关联查询(多表查询)可以使用 table() 方法或和join方法,请看示例:1、table()$list=$user-table( 39;user_statusstats,user...

THINKPHP 中关联查询

THINKPHP 中关联查询(多表查询)可以使用 table() 方法或和join方法,请看示例:

1、table()

  1. $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(); 

2、join()

  1. $user = new Model('user'); 
  2. $list = $user->join('RIGHT JOIN user_profile ON user_stats.id = user_profile.typeid' )->select(); 

3、原生查询

  1. $Model = new Model(); 
  2. $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; 
  3. $voList = $Model->query($sql); 

多表查询

  1. $Model->field('user.name,role.title')->table('think_user user,think_role role')->limit(10)->select(); 

  1. $Model->field('user.name,role.title')->table(array('think_user'=>'user','think_role'=>'role'))->limit(10)->select(); 
分享到:
ThinkPHP实现动态配置config文件及动态清...
ThinkPHP实现动态配置config文件及动态清空缓存 最近在用@ThinkPHP 做系统的时候,要用到一个功能,就要动态的将系统的配置参数保存到Config文件中,以往,我们做系统的时候,项目的配置参数都会直接事先写入到Config/Config.php文件中,然后在项目中应用即可,但是,有些项目,用户需要根据自己的情...
ThinkPHP的全部配置选项 - Thinkphp
ThinkPHP的全部配置选项 return  array(                     'DISPATCH_ON'               =>  true,   // 是否启用Dispatcher         // URL模式: 0 普通模式 1 PATHINFO 2 REWRITE 3 兼容模式 当DIS...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……