PHP code example of guanguans / think-soar

1. Go to this page and download the library: Download guanguans/think-soar library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

guanguans / think-soar example snippets

 php

namespace app\index\controller;

use think\Db;

class Index
{
    public function tests()
    {
        $user = Db::table('fa_user')->where('id', 1)->select();
        $sql = Db::table('fa_user')->fetchSql()->select();
        // 最后一条sql语句评分
        echo soar_score();
        // 指定sql语句评分
        echo soar_score($sql);
        echo soar()->score($sql);
    }
}
 php

namespace app\index\controller;

use think\Db;

class Index
{
    public function tests()
    {
        $user = Db::table('fa_user')->where('id', 1)->select();
        $sql = Db::table('fa_user')->fetchSql()->select();
        // 最后一条sql语句explain信息解读
        echo soar_html_explain();
        echo soar_md_explain();
        // 指定sql语句评分explain信息解读
        echo soar_html_explain($sql);
        echo soar_md_explain($sql);
        echo soar()->htmlExplain($sql);
        echo soar()->mdExplain($sql);
    }
}
 php
$sql = 'selec * from fa_user';
echo soar_syntax_check();
echo soar_syntax_check($sql);
echo soar()->syntaxCheck($sql);
 php
$sql = 'select * from fa_user where id=1';
echo soar_finger_print();
echo soar_finger_print($sql);
echo soar()->fingerPrint($sql);
 php
$sql = 'select * from fa_user where id=1';
var_dump(soar_pretty());
var_dump(soar_pretty($sql));
var_dump(soar()->pretty($sql));
 php
echo soar_md2html("## 这是一个测试");
echo soar()->md2html("## 这是一个测试");
 php
var_dump(soar_help());
var_dump(soar()->help());
 php
$command = "echo '## 这是另一个测试' | /Users/yaozm/Documents/wwwroot/soar-php/soar.darwin-amd64 -report-type md2html";
echo soar_exec($command);
echo soar()->exec($command);