Package Data | |
---|---|
Maintainer Username: | shakahl |
Maintainer Contact: | szelpalsoma@gmail.com (Soma Szelpal) |
Package Create Date: | 2017-05-13 |
Package Last Update: | 2024-03-12 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-16 15:02:31 |
Package Statistics | |
---|---|
Total Downloads: | 5,603 |
Monthly Downloads: | 35 |
Daily Downloads: | 0 |
Total Stars: | 21 |
Total Watchers: | 3 |
Total Forks: | 15 |
Total Open Issues: | 3 |
MySQLi driver (connector) for Laravel 5.4 Eloquent database
composer require shakahl/laravel-eloquent-mysqli
// app.php
'providers' => [
...
'LaravelEloquentMySQLi\MySQLiServiceProvider',
],
You should configure your database connection to use the mysqli
driver.
Example
//...
'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),
],
]
//...
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:
$mysqli = DB::connection()->getMySqli();
// or
$mysqli = DB::connection()->getReadMySqli();
// or
$mysqli = DB::connection()->getPdo();
// or
$mysqli = DB::connection()->getReadPdo();
Unfortunately PHP's mysqli driver does not support named parameter binding so this connector uses custom implementation for it.