mpeter-php / phpmig-mysqli-adapter
phpmig 的适配器,通过 mysqli 提供数据库访问
1.0
2020-06-08 16:00 UTC
Requires
- php: >5.3
- davedevelopment/phpmig: ^1.6
This package is auto-updated.
Last update: 2024-09-09 03:06:26 UTC
README
Phpmig MySQLi 适配器
入门指南
$ php composer.phar require mpeter-php/phpmig-mysqli-adapter
示例
非 CLI 示例
<?php require_once('vendor/autoload.php'); use Phpmig\Adapter\MysqlIAdapter; use Phpmig\Api\PhpmigApplication; use Symfony\Component\Console\Output\NullOutput; $mysqli = new mysqli('db_host', 'db_user', 'db_pass', 'my_database'); (new PhpmigApplication( new ArrayObject( [ 'phpmig.migrations_path' => __DIR__ . DIRECTORY_SEPARATOR . 'migrations', 'phpmig.adapter' => new MysqlIAdapter($mysqli, 'migrations'), 'db' => $mysqli ] ), new NullOutput() ))->up();
CLI 示例
<?php /** * phpmig.php */ use Phpmig\Adapter; $mysqli = new mysqli('db_host', 'db_user', 'db_pass', 'my_database'); return new ArrayObject( [ [ 'phpmig.migrations_path' => __DIR__ . DIRECTORY_SEPARATOR . 'migrations', 'phpmig.adapter' => new Adapter\MysqlIAdapter($mysqli, 'migrations'), 'db' => $mysqli ] ] );