The code is:
DB::enableQueryLog();
User::find(334); // MySql
$res = $this->subjects->simplePage()->paginate(); //Mongo
dd(DB::getQueryLog());
and the output is:
array:1 [
0 => array:3 [
"query" => "select * from `user` where `user`.`id` = ? and `user`.`deleted_at` is null limit 1"
"bindings" => array:1 [
0 => 334
]
"time" => 23.53
]
]
Is there anything wrong? thanks a lot.
DB::getQueryLog() will use the default connection, I think your default connection is mysql. so it print the mysql query log.
Try to use your mongodb connection, something like this:
DB::connection('mongodb')->enableQueryLog();
DB::connection('mongodb')->getQueryLog();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With