The query method is used to execute arbitrary, raw SQL against your database connection.
$users = DB::query('select * from users');
$users = DB::query('select * from users where name = ?', array('test'));
$success = DB::query('insert into users values (?, ?)', $bindings);
$affected = DB::query('update users set name = ?', $bindings);
$affected = DB::query('delete from users where id = ?', array(1));
Laravel provides a few other methods to make querying your database simple. Here's an overview:
$user = DB::first('select * from users where id = 1');
$email = DB::only('select email from users where id = 1');
Sometimes you may wish to access the raw PDO connection behind the Laravel Connection object.
$pdo = DB::connection('sqlite')->pdo;
Note: If no connection name is specified, the default connection will be returned.