public function add() { $postData = I('post.data'); $items = M('items'); $id = findLastId('items', $items); $postData['id'] = (int) $id; $res = $items->data($postData)->add(); $this->ajaxReturn($res); }
public function add() { $data = I('post.data'); $catalogs = M('catalog'); $id = findLastId('catalog', $catalogs); $data['id'] = (int) $id; $res = $catalogs->data($data)->add(); $this->ajaxReturn($res); }
public function regist() { $datas = $this->getPostData(); $u = M('User'); $user = $this->findUserByName($datas['username']); if ($user) { $msg['code'] = -1; $msg['msg'] = '用户名已存在'; } else { $datas['uid'] = findLastId('user', $u); //$u->creat($data); $res = $u->add($datas); if ($res) { $user = $this->findUserByName($datas['username']); $msg['code'] = 1; $msg['msg'] = '注册成功'; } } session('user', $user); cookie('user', $user, 360); echo json_encode($msg); }
public function setid() { $items = M('items'); $id = findLastId('items', $items); $datas['_id'] = '56f00a2c5bf767541900002a'; $data['id'] = $id; print_r($items->where($datas)->save($data)); }