javascript - How to get multiple value from diffrent databases (or models) in codeigniter? -


i have 3 table follow;

experiments_table

  1. id
  2. method
  3. result loq_value min_clb_value max_clb_value
  4. std_deviation

items_table

  1. list item
  2. id
  3. experiment_id
  4. related_table
  5. sampling_method
  6. reg_value

samples_table

  1. sampling_method
  2. related_table,

when choose sampling_method , related_table in samples_table, want automatically create table;

expirement_id || method || result || std_deviation || reg_value

first, experiment_ids items table samples_table.related_table , sampling_method , fill experiment_id , reg_value in table.

than, other parameters (method, result , std_deviation) experiments_table experiment_id find in first step items table.

how in codeigniter 3? please give me suggestion (view, modal_form, model , controller).

this model -> sample_items_model.php

   function get_item_suggestion($keyword = "") {     $experiments_table = $this->db->dbprefix('experiments');      $sql = "select $experiments_table.title     $experiments_table     $experiments_table.deleted=0 , $experiments_table.title '%$keyword%'     limit 30     ";            return $this->db->query($sql)->result(); }  function get_item_info_suggestion($item_name = "") {      $experiments_table = $this->db->dbprefix('experiments');       $sql = "select $experiments_table.*     $experiments_table     $experiments_table.deleted=0  , $experiments_table.title '%$item_name%'     order id desc limit 1     ";      $result = $this->db->query($sql);       if ($result->num_rows()) {         return $result->row();     }  } 

this controller -> samples.php

   /* prepare suggestion of sample item     */  function get_sample_item_suggestion() {     $key = $_request["q"];     $suggestion = array();      $items = $this->sample_items_model->get_item_suggestion($key);      foreach ($items $item) {         $suggestion[] = array("id" => $item->title, "text" => $item->title);     }      $suggestion[] = array("id" => "+", "text" => "+ " . lang("create_new_item"));      echo json_encode($suggestion); }      function get_sample_item_info_suggestion() {     $item = $this->sample_items_model->get_item_info_suggestion($this->input->post("item_name"));     if ($item) {         echo json_encode(array("success" => true, "item_info" => $item));     } else {         echo json_encode(array("success" => false));     } } 

and modal_form script -> item_modal_form.php

    function applyselect2onitemtitle() {     $("#sample_item_title").select2({         showsearchbox: true,         ajax: {             url: "<?php echo get_uri("samples/get_sample_item_suggestion"); ?>",             datatype: 'json',             quietmillis: 250,             data: function (term, page) {                 return {                     q: term // search term                 };             },             results: function (data, page) {                 return {results: data};             }         }     }).change(function (e) {         if (e.val === "+") {             //show simple textbox input new item             $("#sample_item_title").select2("destroy").val("").focus();             $("#add_new_item_to_library").val(1); //set flag add new item in library         } else if (e.val) {             //get existing item info             $("#add_new_item_to_library").val(""); //reset flag add new item in library             $.ajax({                 url: "<?php echo get_uri("samples/get_sample_item_info_suggestion"); ?>",                 data: {item_name: e.val},                 cache: false,                 type: 'post',                 datatype: "json",                 success: function (response) {                      //auto fill method, unit type , rate fields.                     if (response && response.success) {                          if (!$("#sample_item_method").val()) {                             $("#sample_item_method").val(response.item_info.method);                         }                          if (!$("#sample_conc_type").val()) {                             $("#sample_conc_type").val(response.item_info.conc_type);                         }                          if (!$("#sample_item_result").val()) {                             $("#sample_item_result").val(response.item_info.result);                         }                          if (!$("#sample_item_loq_value").val()) {                             $("#sample_item_loq_value").val(response.item_info.loq_value);                         }                          if (!$("#sample_item_min_clb_value").val()) {                             $("#sample_item_min_clb_value").val(response.item_info.min_clb_value);                         }                          if (!$("#sample_item_max_clb_value").val()) {                             $("#sample_item_max_clb_value").val(response.item_info.max_clb_value);                         }                          if (!$("#sample_item_std_deviation").val()) {                             $("#sample_item_std_deviation").val(response.item_info.std_deviation);                         }                                                }                 }             });         }      }); } 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -