I'm using Kohana 3.
我正在使用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).
如果我对$ db-> execute()的结果执行var_dump(),我得到一个1或0来表示它失败了。在这个例子中失败了(返回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.
我怎样才能弄清楚发生了什么错误?它似乎只是暂时失败了。我尝试使用echo mysql_error()但它没有用,正如我所料,因为Kohana 3的db库使用PDO我很确定。
How can I figure out the error that has occurred?
我怎样才能找出发生的错误?
3 个解决方案
#1
2
Try executing this after calling $db->execute()
:
在调用$ db-> execute()之后尝试执行此操作:
echo Database::instance()->last_query
#2
0
Inside the Controller run the profiler:
在Controller内部运行探查器:
$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).
然后在渲染View之后,您将看到已执行的查询列表。通过连接到数据库或使用某些软件(如MySQL Query Browser)来尝试它们。
Good luck!
祝你好运!
#3
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
如果它是SQL错误,它应该抛出异常。您可以捕获此信息并回显它以获取错误。见http://kerkness.ca/wiki/doku.php?id=crud_with_the_query_builder
#1
2
Try executing this after calling $db->execute()
:
在调用$ db-> execute()之后尝试执行此操作:
echo Database::instance()->last_query
#2
0
Inside the Controller run the profiler:
在Controller内部运行探查器:
$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).
然后在渲染View之后,您将看到已执行的查询列表。通过连接到数据库或使用某些软件(如MySQL Query Browser)来尝试它们。
Good luck!
祝你好运!
#3
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
如果它是SQL错误,它应该抛出异常。您可以捕获此信息并回显它以获取错误。见http://kerkness.ca/wiki/doku.php?id=crud_with_the_query_builder