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
其他信息
- 授权协议: MIT
- 更新时间: 2014-02-24