How to output sql statements in ThinkPHP V5.1.18

in the 3: 00 version of thinkphp, you only need to add-> sql () at the end to output the current sql statement to be executed, but how to output the sql statement in 5.1.18.

Db::name ("tab_name")-> where ($where)-> count ();

Apr.25,2021

Db::getLastSql();

enable Trace debugging

set app_trace to true
location is generally in the application/config.php
page after the Trace function is enabled, after running and your page has output, the LOGO:

LOGO Trace:

Trace6SQLTrace

of ThinkPHP will be displayed in the lower right corner of the page.

echo Db::name ('tab_name')-> fetchSql (true)-> where ($where)-> count ();

Menu