<?php namespace appindexcontroller; use thinkDb; class Conn{ public function conn(){ //$data = Db::table('fwzl')->select(); //$data = db("fwzl")->select(); //$data = db("fwzl")->find();//只查一条 //$data = db("student") //->where("id",">",2) //->where("id",">",2) //->where("id","<",5) //->where("sname","like","%王%") //->where("sname","王芳") //->where('id', 1)->whereor('id', 2) //->limit(5)//查前五条 // ->order("id","desc") //->limit(2,3) //->field("sname,class") //->field(["sname","class"]) // ->field(["sname"=>"ss","class"]) //->field("count(*) as tot") //查询总共多少条记录 // ->field(["count(*)"=>"tot"])//查询总共多少条记录 //->field(["id","Sno","Class"],true) //->page("2,5")//显示第二页的5条记录 //->field("sname,count(*) tot")->group("sname") //->field("class,count(*) tot")->group("class")->having("tot>=4") // ->field("sname")->union("select Friend from friend") // ->select(); //->max("sno"); // ->min("sno"); //->avg("sno"); // ->sum("sno"); // ->count("sno"); //dump($data); //插入数据 /*$data =["id"=>"","Sno"=>"115","Sname"=>"黄忠","Ssex"=>"男","Sbirthday"=>"","Class"=>"95065"]; $code = db("student")->insert($data);*/ /* $data =[ ["id"=>"","Sno"=>"155","Sname"=>"司马懿","Ssex"=>"男","Sbirthday"=>"","Class"=>"95064"], ["id"=>"","Sno"=>"156","Sname"=>"赵云","Ssex"=>"男","Sbirthday"=>"","Class"=>"95067"], ["id"=>"","Sno"=>"157","Sname"=>"吕布","Ssex"=>"男","Sbirthday"=>"","Class"=>"95068"], ["id"=>"","Sno"=>"158","Sname"=>"典韦","Ssex"=>"男","Sbirthday"=>"","Class"=>"95069"] ]; $code = db("student")->insertAll($data);*/ //修改数据 //$code = db("student")->where("id",">",22)->update(["Sno"=>"188","Sname"=>"孙权"]); //$code = db("student")->where("id",24)->update(["Sno"=>"198","Sname"=>"孙膑"]); //$code = db("student")->update(["Sname"=>"曹操","id"=>20]); //$code = db("student")->where("id",18)->setField("Sname","太史慈"); //设置自增 // $code = db("student")->where("id",24)->setInc("Sno"); //设置自减 //$code = db("student")->where("id",24)->setDec("Sno"); //$code = db("student")->where("id",24)->setDec("Sno",3); //删除数据 //$code = db("student")->delete(10); /* $code = db("student")->where("id",22)->delete(); $code = db("student")->delete([10,11,12]); $code = db("student")->where("id in(12,13,14)")->delete(); $code = db("student")->where("id>12 and id<15")->delete(); dump($code);*/ } } ?>