SQL query |
Hi, how to create a selection query that retrieves information between two given dates.
thanks for your replies ![]()
Hi hipm, the examples provide by https://stackoverflow.com/questions/4875...es/4876589 doesn't work for me. please look my controller and my model codes and explain me why it doesn't work. thanks for your answers.
This is my mode public function getRecordsKpicon( $data ){ $this->db->select('station_nom, kpi_cate, kpi_nom, kpi_valeur, kpi_date, kpi_heure'); $this->db->from('kpi'); $this->db->join('station_base', 'station_base.station_id = kpi.station_id'); $this->db->where( $data ); $query = $this->db->get(); return $query->result(); } and this is my controller ublic function viewconsukpi(){ $data = array('type_reseau' => $this->input->post('type_reseau'), 'kpi_type'=> $this->input->post('kpi_type'), 'kpi_nom'=> $this->input->post('kpi_nom'), 'region'=> $this->input->post('region'), 'ville'=> $this->input->post('ville'), 'centre'=> $this->input->post('centre'), 'site'=> $this->input->post('site'), 'kpi_date <='=> $this->input->post('datedebut'), 'kpi_date >='=> $this->input->post('datefin') ); $this->load->model('Kpimodel'); $records = $this->Kpimodel->getRecordsKpicon( $data ); $this->load->view('kpilist', ['records'=>$records]); }
HI,
I want to select station_nom, kpi_cate, kpi_nom, kpi_valeur, kpi_date, kpi_heure into the table kpi between two dates. I show you my controller and my model that I wrote. Unfortunately, my request generates the error below: Error Number: 1064 Erreur de syntaxe près de '`NULL` AND `kpi_date` > `IS` `NULL`' à la ligne 10 SELECT `station_nom`, `kpi_cate`, `kpi_nom`, `kpi_valeur`, `kpi_date`, `kpi_heure` FROM `kpi` JOIN `station_base` ON `station_base`.`station_id` = `kpi`.`station_id` WHERE `type_reseau` IS NULL AND `kpi_type` IS NULL AND `region` IS NULL AND `ville` IS NULL AND `centre` IS NULL AND `site` IS NULL AND `kpi_date` < `IS` `NULL` AND `kpi_date` > `IS` `NULL` Filename: C:/wamp/www/CodeIgniter/system/database/DB_driver.php Line Number: 691 |
Welcome Guest, Not a member yet? Register Sign In |