davcs86 / php-mysqlimporter
PHP class for importing big SQL files into MySQL.
Installs: 4 400
Dependents: 1
Suggesters: 0
Security: 0
Stars: 5
Watchers: 1
Forks: 4
Open Issues: 1
Requires
- php: >=5.3.0
- ext-mysqli: *
This package is not auto-updated.
Last update: 2024-11-05 03:00:22 UTC
README
PHP class for importing big SQL files into MySQL server.
This class comes to overpass the problem in phpMyAdmin (and others) , when you can't upload files of decent size through the browser upload.
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.
include("php-mysqlimporter.php"); $mysqlImport = new MySQLImporter("localhost", "user", "password"); $mysqlImport->doImport("yourfile.sql");
Links
- Homepage: http://d-castillo.info/projects/php-mysqlimporter
- Source: https://github.com/davcs86/php-mysqlimporter
- Bugs: https://github.com/davcs86/php-mysqlimporter/issues
Requirements:
- PHP 5.0+
- MySQLi extension
Download
-
As zip from this repository: https://github.com/davcs86/php-mysqlimporter/archive/master.zip
-
With git from a terminal:
git clone https://github.com/davcs86/php-mysqlimporter.git
- Using Composer, add "davcs86/php-mysqimporter" as a dependency in your project's composer.json file:
{
"require": {
"davcs86/php-mysqlimporter": "dev-master"
}
}
How to Use:
Initialization
$mysqlImport = new MySQLImporter($host, $user, $password, $port);
Basic Importing
$mysqlImport->doImport("./sqlfiles/test1.sql");
Error Reporting
if ($mysqlImport->hadErrors){ // Display errors echo "<pre>\n"; print_r($mysqlImport->errors); echo "\n</pre>"; } else { echo "<strong>File imported successfully</strong>"; }
Advanced Importing
- You can specify database.
NOTE: This doesn't override the clause USE in the file, but sets an initial database.
$mysqlImport->doImport("./sqlfiles/test1.sql", "initial_db_name");
- You can create the database (if it doesn't exist).
$mysqlImport->doImport("./sqlfiles/test1.sql", "initial_db_name", true);
- You can drop the database and then create it.
$mysqlImport->doImport("./sqlfiles/test1.sql", "initial_db_name", true, true);
- Or just drop it. Particularly useful if you already got a CREATE statement in your SQL file.
$mysqlImport->doImport("./sqlfiles/test1.sql", "initial_db_name", false, true);
Support
Drop me line on: http://d-castillo.info/contactme/ or to: davcs86@gmail.com
Donations
Did this project help you to save (or earn) some money?
Please, support to the author by making a small donation.