Search code examples
phpmysqlcodeignitercodeigniter-3codeigniter-query-builder

How to retrieve the column values in codeigniter?


I am trying to retrieve the config_value on the basis of config_name from the table as shown in image in codeigniter project. Even i am not able to understand where to start.I find something like this on internet (for Sample).

$this->db->select('age');
$this->db->where('id', '3');
$q = $this->db->get('my_users_table');
$data = $q->result_array();

echo($data[0]['age']);

enter image description here


Solution

  • Do something like this :

    $this->db->where('config_name', 'Account_activation');
    $q = $this->db->get('my_users_table');
    /* if u r fetching one row use row_array instead of result_array*/
    $row = $q->row_array();
    
    echo $row['config_value'];
    

    For more : https://www.codeigniter.com/user_guide/database/index.html