dev-master
9999999-dev http://d-castillo.info/projects/php-mysqlimporter/PHP class for importing big SQL files into MySQL.
MIT
The Requires
- php >=5.3.0
- ext-mysqli *
mysql mysqli import databases mysqldump mysqlimport
Wallogit.com
2017 © Pedro Peláez
PHP class for importing big SQL files into MySQL.
PHP class for importing big SQL files into MySQL server., (*1)
This class comes to overpass the problem in phpMyAdmin (and others) , when you can't upload files of decent size through the browser upload., (*2)
With this class you get the same function, just by uploading the file via FTP and doing the importing with 3 simple commands, e.g., (*3)
include("php-mysqlimporter.php");
$mysqlImport = new MySQLImporter("localhost", "user", "password");
$mysqlImport->doImport("yourfile.sql");
As zip from this repository: https://github.com/davcs86/php-mysqlimporter/archive/master.zip, (*4)
With git from a terminal:, (*5)
git clone https://github.com/davcs86/php-mysqlimporter.git
{
"require": {
"davcs86/php-mysqlimporter": "dev-master"
}
}
$mysqlImport = new MySQLImporter($host, $user, $password, $port);
| Parameter | Description |
|---|---|
| $host | Host (or IP) of the MySQL server. |
| $user | Username to login into the server. |
| $password | Password of the user. |
| $port | Listen port of the MySQL server. _Optional_. It uses the value in mysqli.default_port as default. |
$mysqlImport->doImport("./sqlfiles/test1.sql");
if ($mysqlImport->hadErrors){
// Display errors
echo "<pre>\n";
print_r($mysqlImport->errors);
echo "\n</pre>";
} else {
echo "<strong>File imported successfully</strong>";
}
1) You can specify database.
NOTE: This doesn't override the clause USE in the file, but sets an initial database., (*6)
$mysqlImport->doImport("./sqlfiles/test1.sql", "initial_db_name");
2) You can create the database (if it doesn't exist)., (*7)
$mysqlImport->doImport("./sqlfiles/test1.sql", "initial_db_name", true);
3) You can drop the database and then create it., (*8)
$mysqlImport->doImport("./sqlfiles/test1.sql", "initial_db_name", true, true);
4) Or just drop it. Particularly useful if you already got a CREATE statement in your SQL file., (*9)
$mysqlImport->doImport("./sqlfiles/test1.sql", "initial_db_name", false, true);
Drop me line on: http://d-castillo.info/contactme/ or to: davcs86@gmail.com, (*10)
Did this project help you to save (or earn) some money?
Please, support to the author by making a small donation., (*11)
PHP class for importing big SQL files into MySQL.
MIT
mysql mysqli import databases mysqldump mysqlimport