function addMessage($sender,$getter,$con) { //创建SQL语句 $sql="insert into messages (sender,getter,content,sendTime) values('$sender','$getter','$con',now())"; file_put_contents("/Library/WebServer/Documents/ajax/mylog.txt",$sql."\r", FILE_APPEND); $sqlHelper=new SqlHelper(); return $sqlHelper->execute_dml($sql); }
public function ChangePassword($username, $oldPassword, $newPassword) { $result = false; $sql = "select password from t_admin where username='******'"; //创建一个SqlHelper对象 $sqlHelper = new SqlHelper(); $res = $sqlHelper->execute_dql($sql); if ($row = mysql_fetch_assoc($res)) { //比对密码 if (md5($oldPassword) == $row['password']) { $sql = "update t_admin set password='******' where username='******'"; if ($sqlHelper->execute_dml($sql) != 0) { $result = true; } else { $this->errMessage = "更新失败!"; } } else { $this->errMessage = "原始密码不正确"; } } //资源 mysql_free_result($res); //关闭链接 $sqlHelper->close_connect(); return $result; }
function DeleteNation($nationId) { $sql = "delete from t_Nation where nationId={$nationId}"; // 创建SqlHelper对象实例执行删除 $sqlHelper = new SqlHelper(); return $sqlHelper->execute_dml($sql); }
public function adduser($name, $grade, $email, $score) { $sql = "insert into student(name,grade,email,score)values('{$name}','{$grade}',{$email},{$score})"; $sqlHelper = new SqlHelper(); $res = $sqlHelper->execute_dml($sql); $sqlHelper->close_connect; return $res; }
public function updateEmpUI($id, $name, $grade, $email) { $sql = "update emp set name='{$name}',grade={$grade},email='{$email}' where id={$id}"; $sqlHelper = new SqlHelper(); $res = $sqlHelper->execute_dml($sql); $sqlHelper->close_connect(); return $res; }
function getMessage($getter, $sender) { $sql = "select * from mes where getter='{$getter}' and sender='{$sender}' and state=0"; $mesXML = "<meses>"; $sqlHelper = new SqlHelper(); $mesList = $sqlHelper->execute_dql2($sql); if (count($mesList) != 0) { for ($i = 0; $i < count($mesList); $i++) { $row = $mesList[$i]; $mesXML .= "<id>{$row['id']}</id><sender>{$row['sender']}</sender><getter>{$row['getter']}</getter><con>{$row['content']}</con><sendTime>{$row['sendTime']}</sendTime>"; } $sql = "update mes set state=1 where getter='{$getter}' and sender='{$sender}'"; $res = $sqlHelper->execute_dml($sql); } $mesXML .= "</meses>"; $sqlHelper->close_connect(); return $mesXML; }
function getMessage($getter, $sender) { $sql = "select * from messages where getter='{$getter}' and sender='{$sender}' and isGet=0"; //注意此处的sql语句中sender=“$getter”;是加引号的 //file_put_contents("C:/wamp/www/testinfo.log","sql=".$sql."\r\n", FILE_APPEND); $sqlhelper = new SqlHelper(); $array = $sqlhelper->execute_dql($sql); //dql返回的是数组 $mesInfo = "<mes>"; for ($i = 0; $i < count($array); $i++) { $row = $array[$i]; $mesInfo .= " <mesId>{$row['id']}</mesId>\n\t\t\t\t\t\t <sender>{$row['sender']}</sender>\n\t\t\t\t\t\t <getter>{$row['getter']}</getter>\n\t\t\t\t\t\t <content>{$row['content']}</content>\n\t\t\t\t\t\t <sendTime>{$row['sendTime']}</sendTime>"; } $mesInfo .= "</mes>"; $sqll = "update messages set isGet=1 where getter='{$getter}' and sender='{$sender}'"; // file_put_contents("C:/wamp/www/testinfo.log","sql=".$sql."\r\n", FILE_APPEND); $sqlhelper->execute_dml($sqll); //file_put_contents("C:/wamp/www/testinfo.log", $mesInfo."\r\n",FILE_APPEND); $sqlhelper->close_connect(); return $mesInfo; }
<?php require_once 'SqlHelper.class.php'; require_once 'valiuser.php'; checkUserValidate(); header("content-type:text/html;charset=utf-8"); $id = $_POST['id']; $val = $_POST['value']; //echo $id; //echo $val; $sqlHelper = new SqlHelper(); $sql = "update beipin set olnum={$val} where id={$id}"; //if(empty($val)){ // echo "不能为空"; //}else{ $b = $sqlHelper->execute_dml($sql); if ($b == 1) { echo $val; } else { echo "修改失败"; } //}
function DeleteStudentInfo($zkzh) { $sql = "delete from t_StudentInfo where zkzh='{$zkzh}'"; // 创建SqlHelper对象实例执行删除 $sqlHelper = new SqlHelper(); return $sqlHelper->execute_dml($sql); }
function Useraddemp($id, $name, $password) { //做一个$sql语句 $sql = "insert into admin (id,name,password) values('{$id}','{$name}',md5('{$password}'))"; //同sqlHelper完成添加 $sqlHelper = new SqlHelper(); $res = $sqlHelper->execute_dml($sql); $sqlHelper->close_connect(); return $res; }
<td><input type="submit" value="显示" class="editBtn" name="edit"></td> </tr></table> </div> </form>'; if (isset($_POST)) { if (isset($_POST['add'])) { $name = $_POST['name']; $addjizu = $_POST['addjizu']; $addm_sys = $_POST['addsys']; //echo $name.$addjizu.$addm_sys; //添加系统 if ($name == null) { echo "名称不能为空"; } else { $sqladd = "insert into sys (name,jizu,mainsys) values ('{$name}','{$addjizu}','{$addm_sys}')"; $b = $sqlHelper->execute_dml($sqladd); if ($b == 1) { echo "添加成功"; } else { echo "添加失败"; } } } else { if (isset($_POST['edit'])) { $jizu = $_POST['jizu']; $m_sys = $_POST['sys']; $sql = "select * from sys where jizu={$jizu} and mainsys={$m_sys}"; $res = $sqlHelper->execute_dql($sql); //$row_cnt=$res->num_rows ; $i = 1; //$row_cnt = $res -> num_rows;
$save_path = "xls/"; $file_name = $save_path . date('Ymdhis') . ".xls"; if (copy($tmp, $file_name)) { $xls = new Spreadsheet_Excel_Reader(); $xls->setOutputEncoding('utf-8'); $xls->read($file_name); for ($i = 2; $i <= $xls->sheets[0]['numRows']; $i++) { $name = $xls->sheets[0]['cells'][$i][1]; $type = $xls->sheets[0]['cells'][$i][2]; $num = $xls->sheets[0]['cells'][$i][3]; $eid = $xls->sheets[0]['cells'][$i][4]; $data_values .= "('{$name}','{$type}',{$num},{$eid}),"; } $data_values = substr($data_values, 0, -1); //去掉最后一个逗号 $query = $sqlHelper->execute_dml("insert into beipin (name,type,num,eid) values {$data_values}"); //批量插入数据表中 if ($query) { echo '导入成功!'; } else { echo '导入失败!'; } } } elseif ($action == 'export') { //导出XLS $result = $sqlHelper->execute_dql("select * from student"); $str = "姓名\t性别\t年龄\t\n"; $str = iconv('utf-8', 'gb2312', $str); while ($row = $result->fetch_array()) { $name = iconv('utf-8', 'gb2312', $row['name']); $sex = iconv('utf-8', 'gb2312', $row['sex']);
<td><input type="submit" value="搜索" class="searchBtn" style="line-height:30px; font-size:20px;"></td></tr> </table> </div> </form>'; if (isset($_REQUEST['name'])) { $name = $_REQUEST['name']; $c = $_REQUEST['catalog']; $pageSize = 12; if ($name == null) { echo "<div style='text-align:center; color:red;'>请输入需要查询的内容</div>"; } else { //插入到最近查询列表 $sqlinsert = "insert into recentsearch (name,catalog) values ('{$name}','{$c}')"; $b = $sqlHelper->execute_dml($sqlinsert); if ($c == 1) { //查找备品 if (isset($_GET['page'])) { $page = intval($_GET['page']); } else { $page = 1; } //获取分页 $offset = $pageSize * ($page - 1); $prepage = $page - 1; $nextpage = $page + 1; //获得所有结果列数 $sqlcnt1 = "select count(*) from beipin where name like '%{$name}%'"; $rescnt1 = $sqlHelper->execute_dql($sqlcnt1); $cntrow1 = $rescnt1->fetch_array();
function delEmpById($id){ $sqlHelper=new SqlHelper(); $sql="delete from empmanage where id=$id"; $sqlHelper->execute_dml($sql); }
<tr><td>请重新输入:</td><td><input type="password" name="renewpwd" size="30" /><span style="color:red;">*</span></td></tr> <tr><td colspan="2" align="right" ><input type="submit" value="确定" class="addBtn"><a href="user.php" style="text-decoration:none; color:black; font-size:11px; padding-left:5px;">返回</a></td></tr> </table> </form>'; if ($_POST) { $oldpwd = md5($_POST['oldpwd']); $newpwd = md5($_POST['newpwd']); $renewpwd = md5($_POST['renewpwd']); if ($oldpwd == "" || $newpwd == "" || $renewpwd == "") { echo "密码不能为空"; } else { if (!($newpwd == $renewpwd)) { echo "两次输入必须相同"; } else { //取出旧密码 $sql = "select pwd from users where id = {$uid}"; $res = $sqlHelper->execute_dql($sql); $row = $res->fetch_array(); if ($row['pwd'] == $oldpwd) { $sqlupdate = "update users set pwd='{$newpwd}' where id={$uid}"; $b = $sqlHelper->execute_dml($sqlupdate); if ($b == 1) { echo "修改成功,请关闭或返回"; } else { echo "修改失败"; } } } } }
<?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ require 'SqlHelper.php'; $sql = 'INSERT user(username,password,email)VALUES("chijie5","' . md5(123456) . '","*****@*****.**")'; $sqlhelper = new SqlHelper(); $res = $sqlhelper->execute_dml($sql); echo $res; mysql_free_result($res);
<?php require_once 'SqlHelper.class.php'; require_once 'valiuser.php'; checkUserValidate(); header("content-type:text/html;charset=utf-8"); $uname = $_SESSION['tzname']; $id = $_POST['id']; $val = $_POST['value']; $edtime = date('Y-m-d'); //echo $id; //echo $val; $sqlHelper = new SqlHelper(); $sql = "update beipin set num={$val} where id={$id}"; $sqlhis = "insert into alterbpnum (name,num,edtime,bpid) values ('{$uname}','{$val}','{$edtime}',{$id})"; //if(empty($val)){ // echo "不能为空"; //加上这句修改数量为0的时候会报错 //}else{ $b = $sqlHelper->execute_dml($sql); $s = $sqlHelper->execute_dml($sqlhis); if ($b == 1 && $s == 1) { echo $val; } else { echo "修改失败"; } //}