CodeIgniter Forums

Full Version: Unable to get data into array from database using an extended function built in Core
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]douglasbrownca01[/eluser]
I've created this function that exists as in my core as MY_Input.php to extend the Input function. I'm wanting to pull a query string ouf of a table and then put that value into an array and perform a search - but I can't get the data into the array and when I dump the value, I just see the array but no values.

My sense is that the function isn't working correctly and it's not bringing back anything, but I'm not sure about how to debug to figure out where the breakdown is occurring.

From MY_Inputx.php :

Code:
function load_query($query_id) {
  
  $CI =& get_instance();
  
  $rows = $CI->db->get_where('ci_query', array('id' => $query_id))->result();
  if (isset($rows[0])) {
   parse_str($rows[0]->query_string, $_GET);  
  }
  
}

Controller code:

Code:
$this->input->load_query($query_id);
  

  $query_array = array(
   'fan_type_options'=>$this->input->post('fan_type_options'),
   'fan_motor_type' => $this->input->post('fan_motor_type'),
   'fan_ac_voltage' => $this->input->post('fan_ac_voltage'),
   'fan_cfm' => $this->input->post('fan_cfm'),
   'part-no' => $this->input->post('part-no'),
  );
  
  print_r($query_array);

Querry bring pulled from database :
Code:
fan_type_options=Blower&fan_motor_type=EC&fan;_ac_voltage=&fan;_cfm=∂-no=

Result bring printed when I attempt to use the function:
Code:
Array ( [fan_type_options] => [fan_motor_type] => [fan_ac_voltage] => [fan_cfm] => [part-no] => )

Any insights would be appreciated.


El Forum

[eluser]douglasbrownca01[/eluser]
Here's maybe a more concise question -- how do I see if this line of code is pulling back the the query string from the database? If there is a better way to ask questions, please let me know. I'm new to CodeIgnitor and this community.

Code:
$this->input->load_query($query_id);