Skip to content

Instantly share code, notes, and snippets.

@bubbobne
Last active June 15, 2018 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bubbobne/80c354567a4edc68d414b0df8ba1a5f6 to your computer and use it in GitHub Desktop.
Save bubbobne/80c354567a4edc68d414b0df8ba1a5f6 to your computer and use it in GitHub Desktop.
Some useful statement to use eloquent
<?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