我的PHP代码
$AllAdTypes = UserAdTypes::where('ad_id', $value)
->whereNotIn('ad_typeprice_id', array($ArrString[$i - 1]))
->orderby('created_at', 'ASC')->orderby('ad_id', 'ASC')
->select('ad_typeprice_id')->lists('ad_typeprice_id');
$queries = DB::getQueryLog();
return $last_query = end($queries);
上次查询:
Array ( [query] => select `ad_typeprice_id` from `UserAdTypes` where `ad_id` = ?
and `ad_typeprice_id` not in (?) order by `created_at` asc, `ad_id` asc
[bindings] => Array ( [0] => 82 [1] => 4, 10, 18, 27, 36, 7, 16, 11, 21, 19, 12 )
[time] => 0.44 )
当我在sql中尝试时,没关系。
SELECT `ad_typeprice_id`
FROM `UserAdTypes`
WHERE `ad_id` =82
AND `ad_typeprice_id` NOT
IN ( 4, 10, 18, 27, 36, 7, 16, 11, 21, 19, 12 )
ORDER BY `created_at` ASC , `ad_id` ASC
LIMIT 0 , 30
SQL结果:“13”
但我不知道,查询是对的。我在sql上测试过。结果是错误的。
Laravel查询结果
Array ( [0] => 13 [1] => 18 [2] => 12 [3] => 19 )
如果你检查“$ last_query”结果,我只需要显示([0] => 13)。