ThingkPHP對數(shù)據(jù)庫進(jìn)行改操作
2022-11-22 加入收藏
public function test_check(){ $Experiment = M("Experiment");//實例化Experiment對象。這個對象是跟數(shù)據(jù)庫的表對應(yīng)的。是對experiment表進(jìn)行增刪改查操作 //$sno = I('sno'); $sno = '130906008'; $RowCount = $Experiment -> where("sno = $sno") -> Count();//得到滿足條件的行數(shù) //echo M("Experiment")->getLastSql(); //打印SQL語句到瀏覽器界面上 echo $RowCount;//打印滿足條件的行數(shù) if($RowCount > 0){ $myModel = new \Think\Model(); $result=$myModel->query("select *from g_experiment where sno = $sno;"); $this ->ajaxReturn($result); }