Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shakahl/laravel-eloquent-mysqli
MySQLi driver (connector) for Laravel Eloquent database
https://github.com/shakahl/laravel-eloquent-mysqli
Last synced: about 1 month ago
JSON representation
MySQLi driver (connector) for Laravel Eloquent database
- Host: GitHub
- URL: https://github.com/shakahl/laravel-eloquent-mysqli
- Owner: shakahl
- License: mit
- Created: 2017-05-13T16:08:04.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-03-12T20:32:40.000Z (10 months ago)
- Last Synced: 2024-10-28T22:50:27.764Z (2 months ago)
- Language: PHP
- Size: 15.6 KB
- Stars: 21
- Watchers: 3
- Forks: 15
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# shakahl/laravel-eloquent-mysqli
MySQLi driver (connector) for Laravel **8.x** Eloquent database## Installation
- Install via composer
```sh
composer require shakahl/laravel-eloquent-mysqli
```- After installing, add provider on config/app.php on your project.
```php
// app.php'providers' => [
...'LaravelEloquentMySQLi\MySQLiServiceProvider',
],
```## Usage
You should configure your database connection to use the ```mysqli``` driver.
**Example**
```php
//...
'connections' => [
'mysql' => [
'driver' => 'mysqli', // Sets mysqli driver
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', 3306),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'collation' => env('DB_COLLATION', 'utf8_unicode_ci'),
'prefix' => env('DB_PREFIX', ''),
'timezone' => env('DB_TIMEZONE', '+00:00'),
'strict' => env('DB_STRICT_MODE', false),
],
]
//...
```## Notes
### Accessing underlying mysqli instance
There are some inconsistent methods since Laravel only supports PDO officially.
You can access the raw, underlying MySQLi instance using the following methods on a connection instance:```php
$mysqli = DB::connection()->getMySqli();
// or
$mysqli = DB::connection()->getReadMySqli();
// or
$mysqli = DB::connection()->getPdo();
// or
$mysqli = DB::connection()->getReadPdo();
```### Escaping
Unfortunately PHP's mysqli driver does not support named parameter binding so this connector uses custom implementation for it.