Postgresql Laravel 4-获取原始SQL错误消息

Postgresql Laravel 4-获取原始SQL错误消息,postgresql,laravel,Postgresql,Laravel,我用的是Laravel4和Postgres 如果我在PGAdmin中运行以下语句 SELEC * FROM tables 我收到以下错误消息 ERROR: syntax error at or near "selec" LINE 1: selec * from tables ^ ********** Error ********** ERROR: syntax error at or near "selec" SQL state: 42601 Character: 1

我用的是Laravel4和Postgres

如果我在PGAdmin中运行以下语句

SELEC * FROM tables
我收到以下错误消息

ERROR:  syntax error at or near "selec"
LINE 1: selec * from tables
        ^


********** Error **********

ERROR: syntax error at or near "selec"
SQL state: 42601
Character: 1
现在,当我在Laravel4中运行以下查询时

DB::select("SELEC * FROM tables");
我收到了很多其他额外的错误信息

是否有可能以某种方式获得原始Postgres错误消息?

使用或甚至使用该错误消息如何

使用或者甚至使用它怎么样


进入
php artisan tinker
中,您可以执行以下操作:

try {
    // ...  your code here .. //
} catch ( \Exception $objException ) {
    $arrTrace = $objException->getTrace();
    $query = $arrTrace[0]['args'][0];
    $bindings = $arrTrace[0]['args'][1];
    foreach ($bindings as $i => $binding){
        if ($binding instanceof \DateTime) {
            $bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
        }
        else if (is_string($binding)) {
            $bindings[$i] = "'$binding'";
        }
        else if (is_bool($binding)) {
            $bindings[$i] = $binding ? 'true' : 'false';   
        }
        else if ( $binding === null ) {
            $bindings[$i] = 'NULL';
        }
    }

    // Insert bindings into query
    $query = str_replace(array('%', '?'), array('%%', '%s'), $query);
    $query = trim( vsprintf($query, $bindings) ) . "\n";

    print $query;

}

进入
php artisan tinker
中,您可以执行以下操作:

try {
    // ...  your code here .. //
} catch ( \Exception $objException ) {
    $arrTrace = $objException->getTrace();
    $query = $arrTrace[0]['args'][0];
    $bindings = $arrTrace[0]['args'][1];
    foreach ($bindings as $i => $binding){
        if ($binding instanceof \DateTime) {
            $bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
        }
        else if (is_string($binding)) {
            $bindings[$i] = "'$binding'";
        }
        else if (is_bool($binding)) {
            $bindings[$i] = $binding ? 'true' : 'false';   
        }
        else if ( $binding === null ) {
            $bindings[$i] = 'NULL';
        }
    }

    // Insert bindings into query
    $query = str_replace(array('%', '?'), array('%%', '%s'), $query);
    $query = trim( vsprintf($query, $bindings) ) . "\n";

    print $query;

}

你是说你得到了orangeWhoops调试器的输出?你能告诉我们你收到的错误信息是什么吗?您还可以在
应用程序/存储/日志
中显示错误日志中显示的内容吗?在“呜呜叫”错误屏幕顶部引发的异常应具有以下属性:。请注意,您同时获得了异常消息和使用的SQL/绑定(这应该比股票错误消息更好!)。我很好奇你看到了什么…你是说你得到了orangeWhoops调试器的输出?你能告诉我们你收到的错误信息是什么吗?您还可以在
应用程序/存储/日志
中显示错误日志中显示的内容吗?在“呜呜叫”错误屏幕顶部引发的异常应具有以下属性:。请注意,您同时获得了异常消息和使用的SQL/绑定(这应该比股票错误消息更好!)。我很好奇你看到了什么。。。