Welcome Guest, Not a member yet? Register   Sign In
Seeing query before submitting
#1

[eluser]Unknown[/eluser]
This may be a newbie question, but something I can't find in the docs very easily:

Is there a way to see a query string that's built before actually running the query? I know last_query shows you what was run, but for debugging, I'd like to see it without actually submitting it.

$data = array(
'myfield1' => $EmployeeNo,
'myfield2' => date("Y-m-d")
);

$this->db->where('recordno', $RecordNumber);
$this->db->update('propertytable', $data);

This will actually execute the query -- how do I just get a string of what the query will look like to confirm it's being built correctly with my data?
#2

[eluser]bretticus[/eluser]
The following code works for SELECT statements. Not sure on an UPDATE so your mileage may vary. Feel free to try it and post if it works:

Code:
// get compiled select statement
$compiled_query = $this->db->_compile_select();
echo $compiled_query;

EDIT...Problem may be that you need to call it before calling update. Hmmm????

On second thought, call it before update(). At least you'll get a SELECT version that will show what goes in your WHERE clause.




Theme © iAndrew 2016 - Forum software by © MyBB