1. 程式人生 > >tp5資料庫的查詢、增添、更新、刪除資料

tp5資料庫的查詢、增添、更新、刪除資料

<?php
namespace app\home\controller;
use think\Request;
class Test
{
    public function index()
    {
//查詢

       $result=db("test")->select();
       dump($result);
       $test=array(
           "name"=>"youshe",
           "sex"=>"男",
       );
           db("test")->insert($test);
//  //刪除
//$test["id"]="3";
//db("test")->where($test)->delete();
//
////更新
//        $updatawhere["id"]="5";
//        $updata["name"]="genxing";
//        db("test")->where($updatawhere)->update($updata);
        //新增單條查詢
        $nihao["id"]="6";
        $dantiao=db("test")->where($nihao)->select();
      dump($dantiao);



    }
}