Я хочу получить точное сообщение об этой ошибке - PullRequest
0 голосов
/ 07 марта 2011

Я понимаю, что должен где-то включить mysql_errno y mysql_error вместо 'Query Failed', и я попытался использовать $ results в качестве аргумента, но я не выяснил, как.

Если кто-то может мне помочь, спасибо:

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;
}

1 Ответ

4 голосов
/ 07 марта 2011
 throw new Exception(mysql_error(), EX_QUERY_FAILED);
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...