phpcms模型数据调用
- 提问者网友:骨子里的高雅
- 2021-01-29 10:37
- 五星知识达人网友:举杯邀酒敬孤独
- 2021-01-29 10:49
\phpcms\modules\content\classes\content_tag.class.php
添加如下代码
代码如下:
public function allmodel($data) {
$this->model = getcache('model', 'commons');
$datas=array();
foreach($this->model as $key => $val){
$this->db->set_model($val['modelid']);
if(isset($data['where'])) {
$sql = $data['where'];
} else {
$thumb = intval($data['thumb']) ? " AND thumb != ''" : '';
$sql = "status=99 ".$thumb;
}
$order = $data['order'];
$return = $this->db->select($sql, '*', $data['limit'], $order, '', 'id');
//调用副表的数据
if (isset($data['moreinfo']) && intval($data['moreinfo']) == 1) {
$ids = array();
foreach ($return as $v) {
if (isset($v['id']) && !empty($v['id'])) {
$ids[] = $v['id'];
} else {
continue;
}
}
if (!empty($ids)) {
$this->db->table_name = $this->db->table_name.'_data';
$ids = implode('\',\'', $ids);
$r = $this->db->select("`id` IN ('$ids')", '*', '', '', '', 'id');
if (!empty($r)) {
foreach ($r as $k=>$v) {
if (isset($return[$k])) $datas[]=$return[$k]= array_merge($v, $return[$k]);
}
}
}
}
};
return $datas;
}
- 1楼网友:一叶十三刺
- 2021-01-29 11:17