I have a function that is returning one result “3” and i have another main function that is making a query to the database and within the select statement i need the value to be added to the select statement.
This query returns the one value from the first function:
function insert() {
$siteid = 1;
$field = 3;
$time = "2011-10-11 15:04:56";
$this->db->select('Offset_value', 1)
->from('offset')
->where('siteid', $siteid)
->where('Offset_field', $field)
->where('time <', $time);
$query = $this->db->get()->result_array();
foreach ($query as $row) {
echo $row['Offset_value'];
}
return $query;
}
Then i need that to calculate in this select statement:
$this->db->select("kwh * $dr * $kwp + $this->insert() AS kwhdata")
->from('expected_kwh')
->where('direction', $direction)
->where('tilt', $tilt)
->where('month', $month);
$query2 = $this->db->get()->result_array();
return $query2;
I’m trying to rewrite a stored procedure that was created in mssql and this is how it works there so i’m trying to use the same approach here.
Thanks
I think php just doesn’t like the $obj->method syntax inside quotes. Try this for that select line: