In Kohana 3, how do you figure out errors made during a query?
Asked Answered
S

3

1

I'm using Kohana 3.

I'm writing an update query, and it is working for everything except this one section.

If I do a var_dump() on the results of $db->execute() I get either a 1 or 0 to say it failed or not. It is failing in this example (returning 0).

How can I figure out what error is happening? It justs seems to be silenty failing at the time being. I tried doing echo mysql_error() but it didn't work, as I expected, as Kohana 3's db library uses PDO I'm pretty sure.

How can I figure out the error that has occurred?

Space answered 11/2, 2010 at 5:8 Comment(0)
T
2

Try executing this after calling $db->execute():

echo Database::instance()->last_query
Tsang answered 12/2, 2010 at 14:17 Comment(0)
M
0

Inside the Controller run the profiler:

$this->profiler = new Profiler;

And then after rendering View you'll see a list of queries that were executed. Try them out by connecting to the database or by using some software (like MySQL Query Browser).

Good luck!

Moderato answered 12/2, 2010 at 8:59 Comment(0)
C
0

It should throw an exception if it's a SQL error. You can catch this and echo it to get the error. See http://kerkness.ca/wiki/doku.php?id=crud_with_the_query_builder

Cavin answered 14/2, 2010 at 0:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.