CodeIgniter Forums

Full Version: Very strange database result
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello!
I have a code that fetches settings from the DB but instead of returning a value it returns key name.

The code:

PHP Code:
public function getValue($key){
 
       $CI =& get_instance();
 
       $query $CI->db->query('SELECT ? FROM settings', array($key));
 
       $row=$query->result_array()[0];
 
       var_dump($row);
 
       //return $row[$key];
 
   
The output:

Code:
array(1) { ["max_problems_in_selector"]=> string(24) "max_problems_in_selector" }

The table:
[attachment=1300]
So what $key are you specifying?

Use last_query() to check that you are getting a correct SQL query. Run that one in phpmyadmin and see if that give you the correct results.