这是我的代码
$id = "'".str_replace(",","','",$id)."'"; //'7','8','9'
DB::update("UPDATE `category`
SET status = if(status = 'active', 'inactive', 'active')
WHERE cid in (?)", [$id]);
我需要在laravel5.1中打印此更新查询。
答案 0 :(得分:2)
您可以使用Laravel方法DB::enableQuerylog()
& DB::getQuerylog()
喜欢
DB::enableQuerylog();
$id = "'".str_replace(",","','",$id)."'"; //'7','8','9'
DB::update("UPDATE `category` SET status = if(status = 'active', 'inactive', 'active') WHERE cid in (?)", [$id]);
dd(DB::getQuerylog());