我不明白为什么这个查询只获取1行,但必须有34000行。生成时没有错误$fromDate='2015-10-01',$toDate='2015-10-31'$supervisorIdArray是一个扁平数组。
$this->db->select('production.supervisor_id,production.employee_id,production.operation_id, SUM(production.quantity) as quantity,production_operation.operation_id,production_operation.rate');
$this->db->from('production');
$this->db->join('production_operation','production_operation.operation_id = production.operation_id', 'left');
$this->db->where('production.production_date >=',$fromDate);
$this->db->where('production.production_date <=',$toDate);
$this->db->where_in('production.supervisor_id',$supervisorIdArray);
$this->db->order_by('production.supervisor_id','ASC');
$this->db->order_by('production.employee_id','ASC');
$this->db->order_by('production.operation_id','ASC');
$query = $this->db->get();
$Rows = $query->num_rows();
您使用的是一个组函数SUM
,因此它只生成一行。如果需要多行,请添加group by
$this->db->group_by("production.supervisor_id");