gemini / sql-import
v0.1.1
2024-07-15 10:05 UTC
Requires
- php: >=8.1
- ext-pdo: *
- hyperf/database: ^3.0
- hyperf/db-connection: ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- mockery/mockery: ^1.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^10.0
- swoole/ide-helper: dev-master
Suggests
- swow/swow: Required to create swow components.
This package is auto-updated.
Last update: 2024-11-15 11:01:48 UTC
README
composer create-project gemini/sql-import
使用
<?php use Fan\SqlImport\Importer; $res = di()->get(Importer::class)->import( [ 'driver' => 'mysql', 'host' => '127.0.0.1', 'port' => 3306, 'database' => 'test', 'username' => 'root', 'password' => '', 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', ], file_get_contents(BASE_PATH . '/storage/sql/xxx.sql') );
创建用户
<?php use Fan\SqlImport\Importer; $config = [ 'driver' => 'mysql', 'host' => '127.0.0.1', 'port' => 3306, 'database' => 'test', 'username' => 'root', 'password' => '', 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', ]; $res = di()->get(Privilege::class)->createUser('test', '%', '', $config); $res = di()->get(Privilege::class)->grant('test', '%', '*', '*', $config);