webino/webino-dbdump

Zend Framework 2 数据库导出工具

0.1.0 2016-04-09 11:36 UTC

This package is auto-updated.

Last update: 2024-09-04 22:52:19 UTC


README

Build Status Coverage Status Scrutinizer Quality Score Dependency Status

Latest Stable Version Total Downloads Latest Unstable Version License

用于将数据库导出到SQL文件,并将该文件加载到数据库中的工具。

功能

  • 将整个数据库导出到SQL文件
  • 将SQL文件加载到数据库中

设置

以下步骤是使此模块正常工作所必需的,考虑到zf2-skeleton或非常类似的应用程序

  1. "minimum-stability": "dev"添加到您的composer.json中,因为此模块处于开发中

  2. 运行php composer.phar require webino/webino-db-dump:dev-develop

  3. WebinoDbDump添加到启用模块列表

快速入门

例如,将以下设置添加到您的模块配置中

'di' => [
    'instance' => [
        'alias' => [
            'DefaultDbDump' => \WebinoDbDump\Db\Dump\Dump::class,
        ],
    ],
    'DefaultDbDump' => [
        'parameters' => [
            'adapter' => \Zend\Db\Adapter\Adapter::class,
        ],
    ],
],

注意:根据需要更改DefaultAdapterDump\Zend\Db\Adapter\Adapter::class

然后,将以下代码添加到您的控制器动作中

// We encourage to use Dependency Injection instead of Service Locator
$dbDump = $this->getServiceLocator()->get('DefaultDbDump');

// saves the sql code of the entire database to a file
$dbDump->save('example/dump.sql');

// drops & creates tables/views, triggers and inserts the data
$dbDump->load('example/dump.sql');

// or from string
$dbDump->read(new \WebinoDbDump\Db\Sql\SqlString('CREATE TABLE...'));

注意:如果您不知道如何将WebinoDbDump注入到动作控制器中,请参阅test/resources

注意:如果您想进行压缩,请使用流包装器,例如compress.zlib://example.dump.sql.gz

变更日志

0.2.0 [未发布]

  • 略微重新设计
  • 添加SqlString支持

0.1.0

  • 首次发布

待办事项

  • 测试
  • 支持更多平台(目前仅MySQL)
  • 更好的异常处理
  • 更多选项
  • 事件导出
  • 升级Zend MVC

补充说明

如果您对这个Zend Framework模块感兴趣,请报告任何问题,并且不要犹豫贡献。我们将感激任何对这个模块开发的贡献。

问题 | 分支 | 学习开发