Saturday, 7 September 2013

codeigniter : how to avoid db query returns last statement as key value

codeigniter : how to avoid db query returns last statement as key value

I execute several queries before querying a result in codeigniter:
$sql_drop_temptable = "...blabla...";
$sql_prepare = "it creates a temporary table; where I sum up later...";
$sql_summe = " select sec_to_time(sum(time_to_sec(summands))) from workday;";
$query = $this->db->query($sql_drop_temptable);
$query = $this->db->query($sql_prepare);
$query = $this->db->query($sql_summe)->row();
var_dump($query);
How can I avoid to get the last sql statement ($sql_summe) as the keyname
in the result set ? It is difficult for me get the result in a scalar. The
result looks like:
object(stdClass)[41]
public 'sec_to_time(sum(time_to_sec(summands)))' => string '00:23:54'
(length=8)
Usually I see column names as key-values. But on this one there is no
column name due to the sum function, so it uses the sql statement as key
value. (?)
Thanks.

No comments:

Post a Comment