代码语言:javascript复制
以一个 fh_joinactivity表和fh_activity表联查为例:
方法一:
$data = M()->table('fh_joinactivity as a')->join('fh_activity as b on b.a_id = a.a_id')->where(' a.u_id = 1 ')->select();
注意,方法一这里的表名要带上前缀,最后取2个表的满足where()条件的所有数据
代码语言:javascript复制array (size=2)
0 =>
array (size=18)
'ja_id' => string '12' (length=2)
'ja_name' => string '鍚嶅瓧涓€' (length=9)
'ja_tel' => string '13578945612' (length=11)
'a_id' => string '21' (length=2)
'ja_addtime' => string '1459999999' (length=10)
'u_id' => string '1' (length=1)
'is_read' => string '0' (length=1)
'a_title' => string '娲诲姩浜�' (length=9)
'a_time' => string '1486141800' (length=10)
'a_addr' => string '娲诲姩鍦扮偣浜�' (length=15)
'a_content' => string '<p>娲诲姩浜�<br/></p>' (length=39)
'a_num' => string '13' (length=2)
'a_joinnum' => string '2' (length=1)
'a_img' => string 'Upload/activity/1486089587.png' (length=30)
'a_author' => string '1' (length=1)
'is_show' => string '1' (length=1)
'is_del' => string '0' (length=1)
'add_time' => string '1486089587' (length=10)
1 =>
array (size=18)
'ja_id' => string '13' (length=2)
'ja_name' => string '鍚嶅瓧浜�' (length=9)
'ja_tel' => string '13578948888' (length=11)
'a_id' => string '21' (length=2)
'ja_addtime' => string '1469999999' (length=10)
'u_id' => string '1' (length=1)
'is_read' => string '0' (length=1)
'a_title' => string '娲诲姩浜�' (length=9)
'a_time' => string '1486141800' (length=10)
'a_addr' => string '娲诲姩鍦扮偣浜�' (length=15)
'a_content' => string '<p>娲诲姩浜�<br/></p>' (length=39)
'a_num' => string '13' (length=2)
'a_joinnum' => string '2' (length=1)
'a_img' => string 'Upload/activity/1486089587.png' (length=30)
'a_author' => string '1' (length=1)
'is_show' => string '1' (length=1)
'is_del' => string '0' (length=1)
'add_time' => string '1486089587' (length=10)