<?phpclassUserModel{publicfunctiongetAllUser($itemBegin,$itemCount){// limit i,n i为询结果的索引值(默认从0开始),n是查询结果返回的数量$sql2="select * from user limit $itemBegin,$itemCount";//定义数据库语句$sql="select * from user";//执行数据建库语句// $stmt = $pdo->query($sql);// $stmt2 = $pdo->query($sql2);$stmt=DB::getInstance()->connect()->query($sql);$stmt2=DB::getInstance()->connect()->query($sql2);//处理结果及// 统计结果集个数,给列表分页模块使用$count=$stmt->rowCount();// $user = $stmt->fetchAll();$result=$stmt2->fetchAll();return["users"=>$count,"count"=>$result];}publicfunctionadduser($name,$age,$birthday,$type,$icon,$create_time){global$pdo;//定义sql语句$sql="insert into user (name,type,icon,age,birthday,create_time) values ('$name','$type','$icon','$age','$birthday',$create_time)";//执行sql$result=$pdo->exec($sql);return$result;}publicfunctiondeleteUser($id){global$pdo;// 定义sql语句$sql="delete from user where id = $id";// 执行sql$result=$pdo->exec($sql);return$result;}publicfunctiongetUser($id){# code...global$pdo;// 定义sql语句$sql="select * from user where id = $id";// 执行sql$result=$pdo->query($sql);return$result->fetch();}publicfunctioneditUser($name,$age,$birthday,$type,$icon,$id){global$pdo;// 定义sql语句$sql="update user set name = '$name', age = $age, birthday = '$birthday', type = $type, icon = '$icon' where id = $id";// 执行sql语句获取结果集$result=$pdo->exec($sql);return$result;}//编辑新闻publicfunctioneditNews($name,$age,$birthday,$type,$icon,$id){global$pdo;// 定义sql语句$sql="update user set name = '$name', age = $age, birthday = '$birthday', type = $type, icon = '$icon' where id = $id";// 执行sql语句获取结果集$result=$pdo->exec($sql);return$result;}}