depage/db 问题修复 & 功能扩展

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

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

depage/db

最新稳定版本:1.4.0

Composer 安装命令:

composer require depage/db

包简介

depage-pdo is a small wrapper around the pdo object which allows late/on demand initializition of the database connection.

README 文档

README

PDO Wrapper

A small wrapper around the pdo object which allows late/on demand initialization of the database connection.

Schema

The Schema class imports or updates SQL database schemata. Schemata are described by common SQL files with update instructions in comments. SQL files can also be templates to allow for prefixing/replacement of table identifiers.

Instruction tags

  • @@version
    • mandatory, labels the following code with a version identifier
  • @@tablename
    • mandatory, declares database tablename to be updated
    • marks table identifier for replacement function
  • @@connection
    • marks table identifiers for replacement function

Example

SQL schema file (schema.sql)

# @tablename example
# @version 0.1
CREATE TABLE example (
    uid int(10) unsigned NOT NULL DEFAULT '0',
    pid int(10) unsigned NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

# @version 0.2
ALTER TABLE example
ADD COLUMN did int(10) unsigned NOT NULL DEFAULT '0' AFTER pid;

Import/update in PHP

$schema = new Schema($pdo);
$schema->setReplace(
    function ($tableName) {
        return 'prefix_' . $tableName;
    }
);
$schema->loadFile('schema.sql');

License (dual)

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-02-24