PHP

public function listAllMagazine($firstRow = 0, $listRows = 20) {
        $C = M("Contents");
        $M = M("Magazines");
        $list = $C->field("`path`,`title`,`publish_data`,`magazine_id`")->order("`publish_data` DESC")->where("`type` = 0")->limit(10)->select();
        // 开始遍历从content表中找到的数据,自己补充上title为空的行
        foreach ($list as &$value) {
        	if (empty($value['title'])) {
        		$condition = $value["magazine_id"];
        		$tmp = $M->where("`id` = $condition")->select();
        		$value['title'] = $tmp[0]['title'];
        	}
        }
        
        return $list;
    }

  

原文地址:https://www.cnblogs.com/taxus/p/3270397.html