對數據的添加: 對數據的修改: $data = I('post.'); D('Leave')->Approver = $data['Approver']; D('Leave')->where("id={$data['id']}")->save(); 對數據的查詢: ...
對數據的添加:
public function form() { parent::common(); $obj = D('Leave'); if (IS_POST) { $data = I('post.'); if ($obj->create($data)) { $rs = $obj->add(); if ($rs) { //$this->success('新增成功', 'Approval/approval'); $this->redirect('Approval/approval'); } } else { $this->assign('error', json_encode($obj->getError())); $error1 = $obj->getError(); $this->assign('error1', $error1); } }
對數據的修改:
$data = I('post.');
D('Leave')->Approver = $data['Approver'];
D('Leave')->where("id={$data['id']}")->save();
對數據的查詢:
//控制器中關聯查詢(leave表與user表關聯) D('Leave')->relation(true)->where('Leave.depart_id=2and Leave.job_id!=5')->select(); //leave模型中 protected $_link = [ 'user' => self::BELONGS_TO ];