标签:
include "../tools/Tool.class.php";
class ShopModel
{
//查看所有
public function getAll(){
$getAll=array();
$a =0;
$mysql= Tool::getLink();
$sql="SELECT `demo1`.* FROM `demo1`";
$r=$mysql->query($sql);
while($row=$r->fetch_assoc()){
$getAll[$a]=$row;
$a++ ;
}
$r->free();
$mysql->close();
return $getAll;
}
//新增
public function add($id,$name){
$mysql=Tool::getLink();
$sql="INSERT INTO`demo1`(`id`,`name`) VALUES ($id,‘$name‘)";
$mysql->query($sql);
$mysql->close();
}
//删除
public function delById($delId){
$mysql=Tool::getLink();
$sql="DELETE FROM demo1 where id=$delId";
$mysql->query($sql);
$mysql->close();
}
//查看
public function look($lookId){
$mysql=Tool::getLink();
$sql="SELECT `demo1`.* FROM `demo1` WHERE `id`=$lookId";
$bool=$mysql->query($sql);
$b=$bool->fetch_assoc();
$bool->free();
$mysql->close();
return $b;
}
//修改
public function modById($id,$name){
$mysql=Tool::getLink();
$sql="UPDATE `demo1` SET `name`=‘$name‘ WHERE `id`=$id";
$mysql->query($sql);
$mysql->close();
}
}
标签:
原文地址:http://www.cnblogs.com/cocotian/p/5056156.html