Home >Backend Development >PHP Tutorial >thinkphp3 gets the latest sql statement

thinkphp3 gets the latest sql statement

不言
不言Original
2018-07-06 10:29:022868browse

This article mainly introduces how to get the latest sql statement in thinkphp3, which has a certain reference value. Now I share it with everyone. Friends in need can refer to it

thinkphp 3 Get the latest sql Statement

/**
 * @title  获取最近的sql语句
 * @author lyj [author] [2018-07-06]
 * @param  integer $type [类型 0 打印语句 不为0 返回语句]
 * @return [type]        [description]
 */function getsqlstr($type = 0) 
{    if($type === 0){
        echo &#39;您要的SQL: <br> <h5 style="color:#EE1616;">&#39; . M()->getLastSql() . &#39;<h5>&#39;;
        echo &#39;<br>&#39;;
    }else{
        $res = M()->getLastSql();        return $res;
    }
}

The above is the entire content of this article. I hope it will be helpful to everyone’s study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

How to use model in thinkphp

The above is the detailed content of thinkphp3 gets the latest sql statement. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn