上面是控制器,下面是模型方法
class Publish_log_model extends CI_Model{
/**
* 查询该用户发布日志
* @param unknown_type $uid
* @return unknown
*/
public function user_log($uid,$type,$start,$end,$flag){
//$sql="select * from axxxx";
$this->db->select('project.pname,publish_log.publish_time,publish_log.publish_desc,publish_log.flag,publish_log.snapshot_addr,user.name,publish_log.is_success');
$this->db->from('publish_log');
if($uid!='all'){
$this->db->where(array('publish_log.uid'=>$uid));
}
if($type!='all'){
$this->db->where(array('project.pid'=>$type));
}
if($flag!='all'){
$this->db->where(array('publish_log.flag'=>$flag));
}
if($start!=0 && $end !=0){
$start=strtotime($start);
$end =strtotime($end);
$this->db->where(array('publish_log.publish_time >='=>$start));
$this->db->where(array('publish_log.publish_time <'=>$end));
}
$this->db->join('project','publish_log.pid=project.pid','left');
$this->db->join('user','publish_log.uid=user.uid','left');
$this->db->order_by('id','desc');
$res=$this->db->get()->result_array();
//echo $this->db->last_query();
return $res;
}
} |