Ejemplo n.º 1
0
 public function reg($username, $password)
 {
     $user = M("user");
     $result = $user->where(array('username' => $username))->find();
     if ($result) {
         throw_out("has_been_reg");
     }
     $addArray = array();
     $addArray['username'] = $username;
     $addArray['password'] = $password;
     $uid = $user->add($addArray);
     \think\Session::set("uid", $uid);
     throw_out("success");
 }
Ejemplo n.º 2
0
 public function update($id, $title, $body)
 {
     $uid = \think\Session::get("uid");
     if (!$uid) {
         //如果session中没有uid
         throw_out("not_login");
     }
     $list = M('list');
     //实例化数据库
     $updateArray = array();
     $updateArray['title'] = $title;
     $updateArray['body'] = $body;
     $whereArray['uid'] = $uid;
     $whereArray['id'] = $id;
     if (!$list->where($whereArray)->save($updateArray)) {
         throw_out("update_error");
     } else {
         throw_out("success");
     }
 }