我尝试了各种选择。我只想获得原始的sql;
$payments = Payment::select('Vendor ZIP')->whereIn('Vendor ZIP', $postcodes)->get()->toArray();
我试过了;
//this
dd(array($payments));
//this one
Event::listen('illuminate.query', function($payments)
{
dd(array($payments));
});
//this one too
$sql = str_replace(['%', '?'], ['%%', "'%s'"], $payments->toSql());
$fullSql = vsprintf($sql, $payments->getBindings());
print_r($fullSql);
我主要在浏览器上收到No data received
错误消息。我还能尝试什么?
顺便说一下,查询是100%正确的。
答案 0 :(得分:1)
您可以使用toSql
方法获取原始SQL查询。
$payments = Payment::select('Vendor ZIP')->whereIn('Vendor ZIP', $postcodes)->toSql();