thinkphp6.0快速開發(fā)手冊(cè)(案例版)的疏忽錯(cuò)誤
問題描述
模型:建議更改方式名稱
public function goods_find(){// $find = Goods::find(6);$find = Goods::where('id',27)->find();return $find;}public function goods_select(){ // $select = Goods::select(); // $select = Goods::select(6); $select = Goods::where('id','>',7)->select(); // toArray方法將當(dāng)前的模型實(shí)例輸出為數(shù)組 return $select->toArray();}public function goods_create(){ $create = Goods::create(['cat' => 3,'title' => '新商品','price' => '59.99','add_time' => time() ]); echo $create->id; // 可以直接獲取自增id return $create;}public function goods_update(){# 更新方式一(靜態(tài)方法修改數(shù)據(jù),返回的是當(dāng)前模型的對(duì)象實(shí)例)// $update=Goods::update(// ['price'=>'99.99'],// ['id'=>22],// );// return $update;# 更新方式二(這種方式是最佳的更新方式)$user=Goods::find(23);$user->price='102.99';$save=$user->save();return $save;}public function goods_delete(){# 刪除方法1(靜態(tài)方法刪除數(shù)據(jù),返回的是當(dāng)前模型的對(duì)象實(shí)例) $delete = Goods::where('id',3)->delete(); # 刪除方法2( 根據(jù)主鍵刪除) // $delete = User::destroy(4); return $delete;}
問題解答
回答1:支持一個(gè)
回答2:這個(gè)有什么問題?
相關(guān)文章:
1. 求救一下,用新版的phpstudy,數(shù)據(jù)庫過段時(shí)間會(huì)消失是什么情況?2. php - mysql 模糊搜索問題3. javascript - 在 vue里面用import引入js文件,結(jié)果為undefined4. php工具箱配置第二個(gè)vhost主機(jī)時(shí)不生效,報(bào)錯(cuò)You don’t have permission5. php - 微信開發(fā)驗(yàn)證服務(wù)器有效性6. javascript - 求幫助 , ATOM不顯示界面!!!!7. javascript - js setTimeout在雙重for循環(huán)中如何使用?8. html - 爬蟲時(shí)出現(xiàn)“DNS lookup failed”,打開網(wǎng)頁卻沒問題,這是什么情況?9. [python2]local variable referenced before assignment問題10. javascript - 我的站點(diǎn)貌似被別人克隆了, google 搜索特定文章,除了域名不一樣,其他的都一樣,如何解決?
