Code Monkey home page Code Monkey logo

think-soar's Introduction

think-soar

!本项目不再维护,如果有人愿意接手维护可以联系我。

SQL 语句优化器和重写器

适用于 thinkphp5 SQL 语句优化器扩展包,基于 guanguans/soar-php

Build Status Build Status Scrutinizer Code Quality StyleCI Latest Stable Version Total Downloads License

环境要求

安装

$ composer require guanguans/think-soar --dev

使用

下载 XiaoMi 开源的 SQL 优化器 soar,更多详细安装请参考 soar install

# macOS
$ wget https://github.com/XiaoMi/soar/releases/download/0.11.0/soar.darwin-amd64
# linux
$ wget https://github.com/XiaoMi/soar/releases/download/0.11.0/soar.linux-amd64
# windows
$ wget https://github.com/XiaoMi/soar/releases/download/0.11.0/soar.windows-amd64
# 用其他命令或下载器下载均可以

配置,更多详细配置请参考 soar config

拷贝 config\soar.phpthinkphp 配置目录下,修改对应的配置,并设置 thinkphpapp_debugtrace 配置为 true 。

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语句评分
        echo soar_score();
        // 指定sql语句评分
        echo soar_score($sql);
        echo soar()->score($sql);
    }
}

输出结果:

explain 信息解读

方法调用示例:

<?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);
    }
}

输出结果:

语法检查

方法调用示例:

$sql = 'selec * from fa_user';
echo soar_syntax_check();
echo soar_syntax_check($sql);
echo soar()->syntaxCheck($sql);

输出结果:

At SQL 1 : line 1 column 5 near "selec * from fa_user" (total length 20)

SQL 指纹

方法调用示例:

$sql = 'select * from fa_user where id=1';
echo soar_finger_print();
echo soar_finger_print($sql);
echo soar()->fingerPrint($sql);

输出结果:

select * from fa_user where id = ?

SQL 美化

方法调用示例:

$sql = 'select * from fa_user where id=1';
var_dump(soar_pretty());
var_dump(soar_pretty($sql));
var_dump(soar()->pretty($sql));

输出结果:

SELECT  
  * 
FROM  
  fa_user  
WHERE  
  id  = 1;

markdown 转化为 html

方法调用示例:

echo soar_md2html("## 这是一个测试");
echo soar()->md2html("## 这是一个测试");

输出结果:

...
<h2>这是一个测试</h2>
...

soar 帮助

方法调用示例:

var_dump(soar_help());
var_dump(soar()->help());

输出结果:

···
'Usage of /Users/yaozm/Documents/wwwroot/soar-php/soar:
  -allow-charsets string
    	AllowCharsets (default "utf8,utf8mb4")
  -allow-collates string
    	AllowCollates
  -allow-drop-index
    	AllowDropIndex, 允许输出删除重复索引的建议
  -allow-engines string
    	AllowEngines (default "innodb")
  -allow-online-as-test
    	AllowOnlineAsTest, 允许线上环境也可以当作测试环境
  -blacklist string
    	指定 blacklist 配置文件的位置,文件中的 SQL 不会被评审。
···    

执行任意 soar 命令

方法调用示例:

$command = "echo '## 这是另一个测试' | /Users/yaozm/Documents/wwwroot/soar-php/soar.darwin-amd64 -report-type md2html";
echo soar_exec($command);
echo soar()->exec($command);

输出结果:

...
<h2>这是另一个测试</h2>
...

License

MIT

think-soar's People

Contributors

guanguans avatar imgbotapp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

think-soar's Issues

Weekly Digest (19 July, 2020 - 26 July, 2020)

Here's the Weekly Digest for guanguans/think-soar:


ISSUES

Last week, no issues were created.


PULL REQUESTS

Last week, no pull requests were created, updated or merged.


COMMITS

Last week there were no commits.


CONTRIBUTORS

Last week there were no contributors.


STARGAZERS

Last week there were no stargazers.


RELEASES

Last week there were no releases.


That's all for last week, please 👀 Watch and Star the repository guanguans/think-soar to receive next weekly updates. 😃

You can also view all Weekly Digests by clicking here.

Your Weekly Digest bot. 📆

Weekly Digest (12 July, 2020 - 19 July, 2020)

Here's the Weekly Digest for guanguans/think-soar:


ISSUES

Last week, no issues were created.


PULL REQUESTS

Last week, no pull requests were created, updated or merged.


COMMITS

Last week there were no commits.


CONTRIBUTORS

Last week there were no contributors.


STARGAZERS

Last week there were no stargazers.


RELEASES

Last week there were no releases.


That's all for last week, please 👀 Watch and Star the repository guanguans/think-soar to receive next weekly updates. 😃

You can also view all Weekly Digests by clicking here.

Your Weekly Digest bot. 📆

Weekly Digest (6 April, 2020 - 13 April, 2020)

Here's the Weekly Digest for guanguans/think-soar:


ISSUES

Last week, no issues were created.


PULL REQUESTS

Last week, no pull requests were created, updated or merged.


COMMITS

Last week there were no commits.


CONTRIBUTORS

Last week there were no contributors.


STARGAZERS

Last week there were no stargazers.


RELEASES

Last week there were no releases.


That's all for last week, please 👀 Watch and Star the repository guanguans/think-soar to receive next weekly updates. 😃

You can also view all Weekly Digests by clicking here.

Your Weekly Digest bot. 📆

Weekly Digest (5 July, 2020 - 12 July, 2020)

Here's the Weekly Digest for guanguans/think-soar:


ISSUES

Last week 1 issue was created.
It is still open.

OPEN ISSUES

💚 #10 只能使用5.1吗,tp6.0安装不了, by 2018qihua


PULL REQUESTS

Last week, no pull requests were created, updated or merged.


COMMITS

Last week there were 2 commits.
🛠️ Update composer.json by guanguans
🛠️ Update composer.json by guanguans


CONTRIBUTORS

Last week there was 1 contributor.
👤 guanguans


STARGAZERS

Last week there was 1 stargazer.
shuipf
You are the star! 🌟


RELEASES

Last week there was 1 release.
🚀 v1.1.2


That's all for last week, please 👀 Watch and Star the repository guanguans/think-soar to receive next weekly updates. 😃

You can also view all Weekly Digests by clicking here.

Your Weekly Digest bot. 📆

只能使用5.1吗,tp6.0安装不了

tp6.0安装不了 ,安装提示这个

  • Can only install one of: topthink/think[v6.0.0, No version set (parsed as 1.0.0)].
  • Can only install one of: topthink/think[v6.0.1, No version set (parsed as 1.0.0)].
  • Can only install one of: topthink/think[v6.0.2, No version set (parsed as 1.0.0)].
  • Can only install one of: topthink/think[v6.0.3, No version set (parsed as 1.0.0)].

Weekly Digest (28 June, 2020 - 5 July, 2020)

Here's the Weekly Digest for guanguans/think-soar:


ISSUES

Last week, no issues were created.


PULL REQUESTS

Last week, no pull requests were created, updated or merged.


COMMITS

Last week there were no commits.


CONTRIBUTORS

Last week there were no contributors.


STARGAZERS

Last week there were 3 stagazers.
yufan956932910
easyph
Paladinhanxiao
You all are the stars! 🌟


RELEASES

Last week there were no releases.


That's all for last week, please 👀 Watch and Star the repository guanguans/think-soar to receive next weekly updates. 😃

You can also view all Weekly Digests by clicking here.

Your Weekly Digest bot. 📆

Weekly Digest (2 August, 2020 - 9 August, 2020)

Here's the Weekly Digest for guanguans/think-soar:


ISSUES

Last week, no issues were created.


PULL REQUESTS

Last week, no pull requests were created, updated or merged.


COMMITS

Last week there were no commits.


CONTRIBUTORS

Last week there were no contributors.


STARGAZERS

Last week there were no stargazers.


RELEASES

Last week there were no releases.


That's all for last week, please 👀 Watch and Star the repository guanguans/think-soar to receive next weekly updates. 😃

You can also view all Weekly Digests by clicking here.

Your Weekly Digest bot. 📆

Weekly Digest (3 May, 2020 - 10 May, 2020)

Here's the Weekly Digest for guanguans/think-soar:


ISSUES

Last week, no issues were created.


PULL REQUESTS

Last week, no pull requests were created, updated or merged.


COMMITS

Last week there were no commits.


CONTRIBUTORS

Last week there were no contributors.


STARGAZERS

Last week there were no stargazers.


RELEASES

Last week there were no releases.


That's all for last week, please 👀 Watch and Star the repository guanguans/think-soar to receive next weekly updates. 😃

You can also view all Weekly Digests by clicking here.

Your Weekly Digest bot. 📆

Weekly Digest (26 April, 2020 - 3 May, 2020)

Here's the Weekly Digest for guanguans/think-soar:


ISSUES

Last week, no issues were created.


PULL REQUESTS

Last week, no pull requests were created, updated or merged.


COMMITS

Last week there were no commits.


CONTRIBUTORS

Last week there were no contributors.


STARGAZERS

Last week there were 2 stagazers.
goldeagle
hjw0968
You all are the stars! 🌟


RELEASES

Last week there were no releases.


That's all for last week, please 👀 Watch and Star the repository guanguans/think-soar to receive next weekly updates. 😃

You can also view all Weekly Digests by clicking here.

Your Weekly Digest bot. 📆

Weekly Digest (26 July, 2020 - 2 August, 2020)

Here's the Weekly Digest for guanguans/think-soar:


ISSUES

Last week, no issues were created.


PULL REQUESTS

Last week, no pull requests were created, updated or merged.


COMMITS

Last week there were no commits.


CONTRIBUTORS

Last week there were no contributors.


STARGAZERS

Last week there were no stargazers.


RELEASES

Last week there were no releases.


That's all for last week, please 👀 Watch and Star the repository guanguans/think-soar to receive next weekly updates. 😃

You can also view all Weekly Digests by clicking here.

Your Weekly Digest bot. 📆

Weekly Digest (19 April, 2020 - 26 April, 2020)

Here's the Weekly Digest for guanguans/think-soar:


ISSUES

Last week 1 issue was created.
It is still open.

OPEN ISSUES

💚 #5 [ImgBot] Optimize images, by imgbot[bot]


PULL REQUESTS

Last week, 1 pull request was created, updated or merged.

OPEN PULL REQUEST

Last week, 1 pull request was opened.
💚 #5 [ImgBot] Optimize images, by imgbot[bot]


COMMITS

Last week there were no commits.


CONTRIBUTORS

Last week there were no contributors.


STARGAZERS

Last week there were no stargazers.


RELEASES

Last week there were no releases.


That's all for last week, please 👀 Watch and Star the repository guanguans/think-soar to receive next weekly updates. 😃

You can also view all Weekly Digests by clicking here.

Your Weekly Digest bot. 📆

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.