I\'m new to laravel and I\'m trying to access the raw PDO instance referring to this doc http://laravel.com/docs/5.0/database#accessing-connections by using this code DB::
$pdo = DB::connection()->getPdo();
$query=$pdo->prepare("SHOW TABLES");
$query->execute();//$query->execute(array($bindings ));
while($row=$query->fetch(\PDO::FETCH_BOTH)) {
//Use \PDO::FETCH_ASSOC, \PDO::FETCH_OBJ
//echo $row->yourcolumnname;//its an object when \PDO::FETCH_OBJ
echo $row[0]; //Indexed Array
}
You need either to reference it as \DB
or add a use DB;
at the top of your controller.