課程
/后端開發(fā)
/ThinkPHP
/快速入門ThinkPHP 5.0 --模型篇
where條件不能帶參數(shù)?例如: where('id', $idnum)其中$idnum是一個(gè)變量
2017-09-12
源自:快速入門ThinkPHP 5.0 --模型篇 3-2
正在回答
?use think\Db;
$num = 33;
?$res = Db::name('user')->where('id',$num)->buildSql();
?dump($res);
//頁(yè)面輸出
string(47)?"(?SELECT?*?FROM?`imooc_user`?WHERE??`id`?=?33?)"
你估計(jì)是哪寫錯(cuò)了
可以帶參數(shù),但有的要加條件的,比如:
$user?=?new?User; $user->where('id','>','10')->find();//查詢id大于10的記錄?有條件 $user->where('name','AAA');?????????//查詢name為AAA的記錄
舉報(bào)
Thinkphp5.0已發(fā)布多時(shí),想了解thinkphp 5.0的新特性嗎?老司機(jī)點(diǎn)準(zhǔn)時(shí)出發(fā)
5 回答tp5中where方法如何構(gòu)建分組條件?
1 回答tp5 軟刪除可以添加where條件語句么? 怎么用???教教我
2 回答自動(dòng)update完成,使用 User::where()->update(); 不頂用???
1 回答關(guān)于數(shù)據(jù)庫(kù)查詢的chunk方法
3 回答tp5查詢條件含sql函數(shù)怎么構(gòu)建?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2018-04-26
?use think\Db;
$num = 33;
?$res = Db::name('user')->where('id',$num)->buildSql();
?dump($res);
//頁(yè)面輸出
你估計(jì)是哪寫錯(cuò)了
2017-09-13
可以帶參數(shù),但有的要加條件的,比如: