Welcome Guest, Not a member yet? Register   Sign In
Selecting one value from database?
#1

[eluser]fancms[/eluser]
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

Code:
$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

Code:
$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
Code:
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! Smile


Messages In This Thread
Selecting one value from database? - by El Forum - 10-22-2007, 08:06 AM
Selecting one value from database? - by El Forum - 10-22-2007, 08:18 AM
Selecting one value from database? - by El Forum - 10-22-2007, 08:25 AM
Selecting one value from database? - by El Forum - 10-22-2007, 08:46 AM
Selecting one value from database? - by El Forum - 10-22-2007, 09:15 AM
Selecting one value from database? - by El Forum - 10-22-2007, 09:27 AM
Selecting one value from database? - by El Forum - 10-22-2007, 10:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB