gggordon/php-sql-replacer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

gggordon/php-sql-replacer

Composer 安装命令:

composer require gggordon/php-sql-replacer

包简介

Replace values in `SQL` files especially with serialized php values. Useful for database migrations/clones.

README 文档

README

Build Status Scrutinizer Codecov License Latest Stable Version Latest Unstable Version

PHP SQL Replacer

A utility to replace strings/values in SQL files especially with serialized php values. Useful for database migrations/clones.

Installation

composer require gggordon/php-sql-replacer

Usage

Command Line Usage

./bin/php-sql-replacer --input-file-path="./original.sql" --output-file-path="./updated.sql" --match="Original Text" --replace="New Text"

Required Options:
--input-file-path   : Path of input file
--output-file-path  : Path of output file
--match             : Exact string to look for
--replace           : String to replace match with

Using Code

If you already have the contents stored as a string, you may follow the example below to replace the contents.

<?php

require_once dirname(__FILE__) . '/vendor/autoload.php';

$contents ="insert into test (column1, column2) values ('I like trading','Another Value')";

$replacer = new \PhpSqlReplacer\PhpSqlReplacer();
$updatedContents = $replacer->replaceValue(
    $contents, 
    "trading", 
    "butter"
);

echo $updatedContents;

to get the following output:

insert into test (column1, column2) values ('I like butter','Another Value')

OR

If you are extracting the contents from a file:

<?php

require_once dirname(__FILE__) . '/vendor/autoload.php';

$replacer = new \PhpSqlReplacer\PhpSqlReplacer();
$updatedContents = $replacer->replaceValueFromFile("/path/to/original_file.sql", "trading", "butter", "/path/to/output_file.sql");

echo $updatedContents;

to get the following output:

insert into test (column1, column2) values ('I like butter','Another Value')

and a new file created at /path/to/output_file.sql.

Tests

Testing done using phpunit

phpunit

Documentation

Documentation Generated using phpdox

phpdox

License

MIT License

Maintained by

gggordon

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固