Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dcblogdev/sql-import
PDO import sql from a .sql file
https://github.com/dcblogdev/sql-import
hacktoberfest importer php sql
Last synced: 9 days ago
JSON representation
PDO import sql from a .sql file
- Host: GitHub
- URL: https://github.com/dcblogdev/sql-import
- Owner: dcblogdev
- License: mit
- Created: 2018-07-28T21:55:18.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-25T00:12:20.000Z (over 1 year ago)
- Last Synced: 2024-11-02T09:42:27.318Z (16 days ago)
- Topics: hacktoberfest, importer, php, sql
- Language: PHP
- Homepage:
- Size: 23.4 KB
- Stars: 9
- Watchers: 5
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
Awesome Lists containing this project
README
# php Import SQL
[![Latest Version on Packagist](https://img.shields.io/packagist/v/dcblogdev/sql-import.svg?style=flat-square)](https://packagist.org/packages/dcblogdev/sql-import)
[![Total Downloads](https://img.shields.io/packagist/dt/dcblogdev/sql-import.svg?style=flat-square)](https://packagist.org/packages/dcblogdev/sql-import)![Logo](https://repository-images.githubusercontent.com/142712626/d110ff80-49c1-11eb-8153-e43e3960caca)
PDO import sql from a .sql file
## Install
Using composer include the repository by typing the following into a terminal```
composer require dcblogdev/sql-import
```## Usage
Include the composer autoloader, import the Import namespace.
Define your database file path and credentials, the option dropTables, when set to true, will delete all the tables in the database before the sql file gets imported.
The option forceDropTables is optional and not recommended. When enabled together with dropTables, the deletion of tables will be executed with disabled foreign key checks. Only use this method if you are sure that the integrity of the existing data in the database does not matter.
```php
use Dcblogdev\SqlImport\Import;$filename = 'database.sql';
$username = 'root';
$password = '';
$database = 'sampleproject';
$host = 'dev';
$dropTables = true;
$forceDropTables = false;new Import($filename, $username, $password, $database, $host, $dropTables, $forceDropTables);
```