$ php artisan vendor:publish --provider="Guanguans\\LaravelSoar\\SoarServiceProvider"
生成 sql 评分报告示例
use App\Models\Member;
Member::query()
->select([
'id',
'nickname',
->where('id', 100)
->ddSoarScore()
DB::table('yb_member')
->select('*')
->join('yb_member_account as yb_member_account', 'yb_member_account.member_id', '=', 'yb_member.id')
->whereRaw('1 <> 1')
->where('yb_member.nickname', 'like', 'admin')
->where('yb_member.username', 'like', '%admin%')
->whereRaw("substring(yb_member.username, 1, 5) = 'admin'")
->whereIn('yb_member.id', [110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120])
->orWhereNotNull('yb_member.realname')
->groupByRaw("yb_member.status, '100'")
->having('yb_member.id', '>', '100')
->inRandomOrder()
->ddSoarScore()
生成 explain 信息解读报告示例
DB::table('yb_member')
->select('*')
->join('yb_member_account as yb_member_account', 'yb_member_account.member_id', '=', 'yb_member.id')
->whereRaw('1 <> 1')
->where('yb_member.nickname', 'like', 'admin')
->where('yb_member.username', 'like', '%admin%')
->whereRaw("substring(yb_member.username, 1, 5) = 'admin'")
->whereIn('yb_member.id', [110, 120])
->orWhereNotNull('yb_member.realname')
->groupByRaw("yb_member.status, '100'")
->having('yb_member.id', '>', '100')
->inRandomOrder()
->ddSoarHtmlExplain()
美化 sql 语句
DB::table('yb_member')
->select('*')
->join('yb_member_account as yb_member_account', 'yb_member_account.member_id', '=', 'yb_member.id')
->whereRaw('1 <> 1')
->where('yb_member.nickname', 'like', 'admin')
->where('yb_member.username', 'like', '%admin%')
->whereRaw("substring(yb_member.username, 1, 5) = 'admin'")
->whereIn('yb_member.id', [110, 120])
->orWhereNotNull('yb_member.realname')
->groupByRaw("yb_member.status, '100'")
->having('yb_member.id', '>', '100')
->inRandomOrder()
->dumpSoarPretty()
其他使用示例
\Soar::score($sql);
\Soar::mdExplain($sql);
\Soar::htmlExplain($sql);
\Soar::syntaxCheck($sql);
\Soar::fingerPrint($sql);
\Soar::pretty($sql);
\Soar::md2html($sql);
\Soar::help($sql);
\Soar::exec($command);
guanguans
244.1k
粉丝