I need to select one value from one row in the database. With the database class I used previously before finding CI I could accomplish this by doing
$variable = $db->get_var("SELECT somevalue FROM sometable WHERE something='therowvalue'");
This would allow me to use $variable as-is throughout my code.
I’ve been trying to figure out how to do this (select one value from a table) in CI. Right now I have
$this->db->select('value'); #Because I need the value
$this->db->where('variable', 'siteoverview'); #Because I need the variable column entitled siteoverview
$grab_cache = $this->db->get("settings"); #From the settings table
This produces
CI_DB_mysql_result Object
(
[conn_id] => Resource id #27
[result_id] => Resource id #31
[result_array] => Array
(
)
[result_object] => Array
(
)
[current_row] => 0
[num_rows] => 1
)
I’m a bit lost here. I haven’t been able to find my answer in the docs, the forums, or the wiki. I know this is a basic question (and I’ll likely feel pretty dumb when I find/get the answer) but I’m hoping someone will be kind enough to clarify a bit.
Thanks! ![]()
