laravel原生sql
转自:https://www.cnblogs.com/zouzhe0/p/6307077.html
DB::insert('insert into users (id, name, email, password) values (?, ?, ? , ? )',[1, 'Laravel','laravel@test.com','123']);
$user = DB::select('select * from users where id = ?', [1]); //我们还 可以看到在执行查询的时候使用了参数绑定,以避免SQL注入。除此之//外还可以使用命名绑定: $user = DB::select('select * from users where id = :id', [':id'=>1]);
$affected = DB::update('update users set name="LaravelAcademy" where name = ?', ['Academy']);
$deleted = DB::delete('delete from users');