我想对行进行分组,并且数据将基于日期(表标题)放在单行中。目前,我已经尝试了很多方法,但是没有成功
查看此图片以了解更多click here to see the picture
这是我的目标结果:click here
以下是我到目前为止的代码
控制器
MongoError: unknown command findAndModify
at Connection.<anonymous> (node_modules/mongodb-core/lib/connection/pool.js:443:61)
at processMessage (node_modules/mongodb-core/lib/connection/connection.js:364:10)
at TLSSocket.<anonymous> (node_modules/mongodb-core/lib/connection/connection.js:533:15)
模型
public function index()
{
$trkh_d = $this->input->post('trkh_d');
$trkh_m = $this->input->post('trkh_m');
$trkh_y = $this->input->post('trkh_y');
$data = array(
'trkh_m' => $trkh_m,
'trkh_y' => $trkh_y
);
if ($trkh_m == "" || $trkh_y == "") {
$data['date_range_error_message'] = "Both date fields are required";
} else {
$result = $this->timetable_m->show_data_month($data);
if ($result != false) {
$data['result_display'] = $result;
} else {
$data['result_display'] = "No record found !";
}
}
$this->template->load('tpl_timetable', 'timetable/timetable_form', $data);
查看
public function show_data_month($data)
{
$this->db->select("
model_name as MODEL,
material_no as MATERIALNO,
material_name as MATERIALDESC,
date_format(start_date, '%d') as STARTDATE,
target_qty as TARGET");
$this->db->from('rom_planning');
$this->db->where('MONTH(start_date)', $data['trkh_m']);
$this->db->where('YEAR(start_date)', $data['trkh_y']);
$this->db->order_by('MATERIALDESC');
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result_array();
} else {
return false;
}
}
我希望有人能帮助我或给我一些想法。
提前谢谢