public static function getLastSQL($type = self::SQL_RETURN_TYPE_STRING, $withEagerLoading = false)
    {
        $queries = DB::getQueryLog();
        $ret = [' -------- last queries --------'];
        if ($withEagerLoading) {
            foreach ($queries as $query) {
                if (self::SQL_RETURN_TYPE_STRING == $type) {
                    $queryString = DBUtil::bindDataToQuery($query);
                    $ret[] = $queryString;
                } else {
                    $ret[] = $query;
                }
            }
        } else {
            $last_query = end($queries);
            if ($type == 'str') $last_query = DBUtil::bindDataToQuery($last_query);
            $ret[] = $last_query;
        }
        $ret = implode("\n\t\t", $ret);
        $ret = "\n" . $ret;
        return $ret;
    }
public static function getLastSQL($type = self::SQL_RETURN_TYPE_STRING, $withEagerLoading = false)
    {
        $queries = DB::getQueryLog();
        $ret = [' -------- last queries --------'];
        if ($withEagerLoading) {
            foreach ($queries as $query) {
                if (self::SQL_RETURN_TYPE_STRING == $type) {
                    $queryString = DBUtil::bindDataToQuery($query);
                    $ret[] = $queryString;
                } else {
                    $ret[] = $query;
                }
            }
        } else {
            $last_query = end($queries);
            if ($type == 'str') $last_query = DBUtil::bindDataToQuery($last_query);
            $ret[] = $last_query;
        }
        $ret = implode("\n\t\t", $ret);
        $ret = "\n" . $ret;
        return $ret;
    }
public static function getLastSQL ( $ type = self :: SQL_RETURN_TYPE_STRING , $ withEagerLoading = false ) { $ queries = DB :: getQueryLog ( ) ; $ ret = [ ' -------- last queries --------' ] ; if ( $ withEagerLoading ) { foreach ( $ queries as $ query ) { if ( self :: SQL_RETURN_TYPE_STRING == $ type ) { $ queryString = DBUtil :: bindDataToQuery ( $ query ) ; $ ret [ ] = $ queryString ; } else { $ ret [ ] = $ query ; } } } else { $ last_query = end ( $ queries ) ; if ( $ type == 'str' ) $ last_query = DBUtil :: bindDataToQuery ( $ last_query ) ; $ ret [ ] = $ last_query ; } $ ret = implode ( "\n\t\t" , $ ret ) ; $ ret = "\n" . $ ret ; return $ ret ; }
return the SQL statement just have been executed.
@param int  $type SQL_RETURN_TYPE_STRING by default.
return string when SQL_RETURN_TYPE_STRING,
return Array when SQL_RETURN_TYPE_ARRAY, which contains query params and values
@param bool $withEagerLoading return last SQL statement when false, Or all SQL statements.
@return mixed|string
return the SQL statement just have been executed .