定制 fos1/sf-s-q-l-tools-plugin 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fos1/sf-s-q-l-tools-plugin

Composer 安装命令:

composer require fos1/sf-s-q-l-tools-plugin

包简介

Doctrine SQL Tools Plugin for Symfony1. Task to execute SQL files with triggers, procedures and events in order. Compatible with any kind of database engines.

README 文档

README

The sfSQLToolsPlugin is a symfony1 plugin that provides easy way to execute database specific features like stored procedures, triggers, events and any other SQL commands.

Contents

It gives you one task to execute SQL files with additional options.

Installation

  • Download the plugin

Add the plugin your composer.json requirements:

  "require": {
    ...
    "fos1/sf-s-q-l-tools-plugin": "1.0.*",
    ...
  • Install the plugin: edit your ProjectConfiguration.class.php file
  $this->enablePlugins(array('sSQLToolsPlugin');
  • Clear you cache symfony cc

Usage

symfony sql:execute [--application[="..."]] [--env[="..."]] [--dir[="..."]] [--dir-depth[="..."]] [--file[="..."]] [--exclude[="..."]] [--delimiter[="..."]]

Options:

  • --application The application name (default: 1)
  • --env The environment (default: dev)
  • --dir The directory where to look for *.sql file (default: data/sql/tasks)
  • --dir-depth Search directory depth (default: 0)
  • --file One file to be executed
  • --exclude Exclude file pattern or file list separated by commas
  • --delimiter Query delimiter (default: ~)

Description:

The sql:execute task reads *.sql files in search directory and then runs them in order

  • Call it with:

    $ ./symfony sql:execute

  • To work in certain environment run this command with --env option

    $ ./symfony sql:execute --env=prod

  • To use certain application`s database settings use --application option

    $ ./symfony sql:execute --application=frontend

  • If you need to customize the *.sql location dirname (default is "data/sql/tasks"), you can pass a --dir option:

    $ ./symfony sql:execute --dir=data/my/folder

  • To exclude one or more files from --dir folder use --exclude option. In order to exclude "00-misc.sql" file from "data/my/folder" directory use:

    $ ./symfony sql:execute --dir=data/my/folder --exclude="00-misc.sql"

  • In order to exclude many files from "data/my/folder" directory, separate is by commas:

    $ ./symfony sql:execute --dir=data/my/folder --exclude="00-misc.sql, 10-triggers.sql, 20-events.sql"

  • Or you can use glob patterns (exclude all filename which contains words: U_"old"_ and "backup"):

    $ ./symfony sql:execute --dir=data/my/folder --exclude="old,backup"

  • To run only one specific SQL file use --file:

    $ ./symfony sql:execute --file=data/sql/tasks_1/alter-tables.sql

  • or to run one specific file in directory "data/sql/tasks_1"

    $ ./symfony sql:execute --dir=data/sql/tasks_1 --file=alter-tables.sql

  • To search for *.sql file until sub folder certain level use --dir-depth option:

    $ ./symfony sql:execute --dir-depth=5

  • To search for *.sql file recursively pass "*" to --dir-depth option:

    $ ./symfony sql:execute --dir-depth=*

Example

This is your file "00-procedures.sql" content (MySQL)

        CREATE PROCEDURE `simpleproc`(OUT param1 INT)
        BEGIN
            SELECT COUNT(*) INTO param1 FROM t;
        END
        ~
        CREATE FUNCTION `hello`(s CHAR(20)) RETURNS CHAR(50)  RETURN CONCAT('Hello, ',s,'!');
        ~
        CREATE PROCEDURE molo() SELECT 'Molo';
  • Now, setup your DBMS conntecion in config/databases.yml (if you haven't done this yet)
  • And execute this procedures in development environment: symfony sql:execute --env=dev --file=data/sql/00-procedures.sql
  • After you run this task, you should get the following output:
>> sql:execute start
>> sql:execute [00-procedures.sql] CREATE PROC...OUNT(*) INTO param1 FROM t; END
>> sql:execute [00-procedures.sql] CREATE FUNC...RETURN CONCAT('Hello, ',s,'!');
>> sql:execute [00-procedures.sql] CREATE PROCEDURE molo() SELECT 'Molo';
>> sql:execute end

Unit test

  • Unit tests (14 of 14) successfully completed.
  • Tested with:
    • MySQL 5.0.84
    • MySQL 5.1.40
    • PostgreSQL 8.3.8

fos1/sf-s-q-l-tools-plugin 适用场景与选型建议

fos1/sf-s-q-l-tools-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 375 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 08 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 fos1/sf-s-q-l-tools-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 fos1/sf-s-q-l-tools-plugin 我们能提供哪些服务?
定制开发 / 二次开发

基于 fos1/sf-s-q-l-tools-plugin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 375
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 24
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 6
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-20