PHP code example of gemini / sql-import

1. Go to this page and download the library: Download gemini/sql-import library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gemini / sql-import example snippets




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')
);



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);