tablePrefix ='tab_'; /* 执行构造方法 */ parent::__construct($name, $tablePrefix, $connection); } /** * 广告列表 */ public function lists($map=array(),$order='create_time desc') { if (PID>0) { $map['promote_id'] = PID; $time = time(); $map['_string'] = "(start_time=0 or start_time < $time) and (end_time=0 or end_time > $time)" ; $data = $this->field('tab_site_adv.*,tab_adv_pos.width,tab_adv_pos.height')->join('tab_adv_pos on tab_adv_pos.id=tab_site_adv.pos_id','right')->where($map)->order($order)->select(); foreach($data as $k => $v) { if ($v['data']>0) { $cover = get_cover($v['data'],'path'); if(strpos($cover,'http')!==false){ $cover = $cover; }else{ $cover = $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'].$cover; } $data[$k]['data']=$cover; } } } else { $data = null; } return $data; } /** * 广告详情 */ public function detail($id) { if (!is_numeric($id) || $id <1) {return null;} if (PID<=0) {return null;} $map['promote_id'] = PID; $map['id']= $id; return $this->where($map)->find(); } }