Last active
June 15, 2018 12:11
-
-
Save bubbobne/80c354567a4edc68d414b0df8ba1a5f6 to your computer and use it in GitHub Desktop.
Some useful statement to use eloquent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Database\Capsule\Manager as DB; | |
/* | |
*Init eloquent illuminate | |
* | |
*DBDRIVER => "pgsql","sqlite","mysql" | |
* | |
*DBNAME is the complete path of the file if the driver is sqlite. | |
*/ | |
$capsule = new DB(); | |
$capsule->addConnection([ | |
"driver" => DBDRIVER, | |
"host" => DBHOST, | |
"database" => DBNAME, | |
"username" => DBUSER, | |
"password" => DBPASS, | |
"charset" => "utf8", | |
"collation" => "utf8_unicode_ci", | |
"prefix" => "", | |
]); | |
$capsule->setAsGlobal(); | |
$capsule->bootEloquent(); | |
/* | |
*Debug, get last query | |
*/ | |
DB::enableQueryLog(); | |
//do query | |
echo(json_encode(DB::getQueryLog())); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment