laravel sql query
snippet in sql

laravel wher in

user6075

$users = DB::table('users')
                    ->whereIn('id', [1, 2, 3])
                    ->get();

laravel query db::raw

user2937

$someVariable = Input::get("some_variable");

$results = DB::select( DB::raw("SELECT * FROM some_table WHERE some_col = '$someVariable'") );

db name laravel

user3432

DB::connection()->getDatabaseName() //laravel

laravel sql query

user2850

use Illuminate\Support\Facades\DB;

$users = DB::select('select * from users');

foreach ($users as $user) {
    echo $user->name;
}

db::statement in laravel

user9789

DB::statement('DROP TABLE users');
DB::statement('ALTER TABLE projects AUTO_INCREMENT=123');