目前,我的代码由两个查询执行,并且正在运行。 这里的问题是,有没有办法将它们作为一个整体来执行?
广告表
活动日志表
我想要什么?
基本上,我需要查询来从广告表中选择行,但有两个条件:
我的代码:
$timeperiods = timeperiods($this->timezone);
$subscription = $this->db
->select('*')
->from('advertisements')
->get();
if ($subscription->num_rows() > 0){
$subs = $subscription->result_array()[0];
$rows = $subscription->num_rows();
$activitylogs = $this->db
->select('*')
->from('activitylogs')
->where('action', 'visited')
->where('path', $subs['web_address'])
->where("timeperiod NOT BETWEEN {$timeperiods['today_start']} AND {$timeperiods['today_end']}", FALSE, FALSE)
->limit(1)->order_by('timeperiod', 'ASC')
->get();
if ($activitylogs->num_rows() > 0){
print_r( $this->security->xss_clean($activitylogs->result_array()[0]) );
}
else{
print_r($this->security->xss_clean($subs));
}
}
else{
echo 'not found';
}