W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
如果配置好數(shù)據(jù)庫(kù)連接,就可以通過(guò) DB facade 執(zhí)行查找。
$results = DB::select('select * from users where id = ?', [1]);
select 方法會(huì)返回一個(gè) array 結(jié)果。
You may also execute a query using named bindings:
$results = DB::select('select * from users where id = :id', ['id' => 1]);
DB::insert('insert into users (id, name) values (?, ?)', [1, 'Dayle']);
DB::update('update users set votes = 100 where name = ?', ['John']);
DB::delete('delete from users');
注意: update 和 delete 語(yǔ)法會(huì)返回在操作中所影響的數(shù)據(jù)筆數(shù)。
DB::statement('drop table users');
你可以使用 DB::listen 方法,去監(jiān)聽(tīng)查找的事件:
DB::listen(function($sql, $bindings, $time)
{
//
});
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: