public function actionApply() { //获取客户端POST过来的数据 $stuId = $_POST['stuId']; $assetName = $_POST['assetName']; $specification = $_POST['specification']; $loanTime = $_POST['loanTime']; $returnTime = $_POST['returnTime']; //计算申请时间 $applyTime = date('Y-m-d H:m:s', time()); //通过stuId查找学生信息 $stuData = StStudent::model()->findByPk($stuId); $stuData = json_decode(CJSON::encode($stuData), TRUE); //插入数据库 $apply = new AsApply(); // 资产申请数据库表 $apply->stuId = $stuId; $apply->stuName = $stuData['stuName']; $apply->assetName = $assetName; $apply->specification = $specification; $apply->applyTime = $applyTime; $apply->RFID = "123"; $apply->borrowTime = $loanTime; $apply->returnTime = $returnTime; $apply->stuTelNum = '123'; $apply->type = 'static'; if ($apply->save() > 0) { // 数据库表类的函数save(),存储是否成功,来自yii框架 $retArr = array('flag' => 1); exit(json_encode($retArr)); } else { $retArr = array('flag' => 0); exit(json_encode($retArr)); } }
public function actionDelete($stuId) { $data = StStudent::model()->deleteByPk($stuId); echo "<script language=\"JavaScript\">alert(\"删除成功\");</script>"; header("Location:index.php?r=student/studentManage/findAll"); }