Php 我想从这个错误中得到确切的信息
我知道我必须在这里的某个地方包含mysql\u errno y mysql\u error,而不是'Query Failed',并且我尝试使用$results作为参数,但我还没有找到方法 如果有人能帮我,谢谢:Php 我想从这个错误中得到确切的信息,php,mysql,exception-handling,Php,Mysql,Exception Handling,我知道我必须在这里的某个地方包含mysql\u errno y mysql\u error,而不是'Query Failed',并且我尝试使用$results作为参数,但我还没有找到方法 如果有人能帮我,谢谢: static function execSQl2($query) { /* Execute a SQL query on the database passing the tablename and the sql query. Retur
static function execSQl2($query)
{
/*
Execute a SQL query on the database
passing the tablename and the sql query.
Returns the LAST_INSERT_ID
*/
$db = null;
$lastid = null;
//echo "query is $query";
try
{
$db = Model::getConnection();
$results = $db->query($query);
if(!$results) {
throw new Exception('Query failed', EX_QUERY_FAILED);
}
$lastid = $db->insert_id;
}
catch(Exception $e)
{
/* errors are handled higher in the
object hierarchy
*/
throw $e;
}
Model::closeConnection($db);
return $lastid;
}
看起来您正在使用某种框架。您应该查看它的文档,了解正在使用的数据库类是如何报告错误的。看起来您正在使用某种框架。您应该查看它的文档,了解正在使用的数据库类如何报告错误。
throw new Exception(mysql_error(), EX_QUERY_FAILED);