Fork me on GitHub
代码改变世界

thinkphp 多表关联查询 设置多条件

2012-10-08 23:45  freefei  阅读(1074)  评论(0编辑  收藏  举报
$this->_link = array( 'NavigationUrl'=>array( 'mapping_type'=>HAS_MANY, 'class_name' =>'NavigationUrl', 'foreign_key'=>'cateid', 'condition'=> "uid=$a", ), 'Navicate'=>array( 'mapping_type'=>HAS_MANY, 'class_name' =>'NavigationUrl', 'foreign_key'=>'cateid', 'condition'=> "catetop=1", ), ); 其实 关联的都是一个表 但是确写了两个数组 目的是返回的数组中返回两个二维数组 分别为 ["NavigationUrl"] ["Navicate"] [1] => array(4) { ["id"] => string(1) "2" ["catename"] => string(6) "影视" ["NavigationUrl"] => array(4) { [0] => array(9) { ["url_id"] => string(1) "9" ["webname"] => string(6) "优酷" ["url"] => string(20) "http://www.youku.com" ["cateid"] => string(1) "2" ["uid"] => string(2) "23" ["time"] => string(10) "1349596263" ["hots"] => string(1) "0" ["top"] => string(1) "0" ["catetop"] => string(1) "1" } [1] => array(9) { ["url_id"] => string(2) "10" ["webname"] => string(6) "酷六" ["url"] => string(18) "http://www.ku6.com" ["cateid"] => string(1) "2" ["uid"] => string(2) "23" ["time"] => string(10) "1349596281" ["hots"] => string(1) "0" ["top"] => string(1) "0" ["catetop"] => string(1) "0" } [2] => array(9) { ["url_id"] => string(2) "12" ["webname"] => string(7) "youtube" ["url"] => string(22) "http://www.youtube.com" ["cateid"] => string(1) "2" ["uid"] => string(2) "23" ["time"] => string(10) "1349596316" ["hots"] => string(1) "0" ["top"] => string(1) "1" ["catetop"] => string(1) "0" } [3] => array(9) { ["url_id"] => string(2) "16" ["webname"] => string(9) "爱奇异" ["url"] => string(16) "http://qqiyi.vom" ["cateid"] => string(1) "2" ["uid"] => string(2) "23" ["time"] => string(10) "1349667378" ["hots"] => string(1) "0" ["top"] => string(1) "0" ["catetop"] => string(1) "0" } } ["Navicate"] => array(1) { [0] => array(9) { ["url_id"] => string(1) "9" ["webname"] => string(6) "优酷" ["url"] => string(20) "http://www.youku.com" ["cateid"] => string(1) "2" ["uid"] => string(2) "23" ["time"] => string(10) "1349596263" ["hots"] => string(1) "0" ["top"] => string(1) "0" ["catetop"] => string(1) "1" } } }
@ https://github.com/ranmufei

校友通微信小程序

校友通微信小程序