废话不多说了,直接给大家贴代码了,具体代码如下所示:
db->createCommand("select * from goods ")->queryAll(); return $this->render('index',['data'=>$data]); } Public function actionXx() { $id=yii::$app->request->get('id'); $data=yii::$app->db->createCommand("select * from goods where id='$id'")->queryOne(); return $this->render('info',['data'=>$data]); } Public function actionAdd() { $a=yii::$app->redis; if (Yii::$app->request->isPost) { $data=yii::$app->request->post(); $res=yii::$app->db->createCommand()->insert('goods',$data)->execute(); if($res) { for ($i=0; $i <$data['counts'] ; $i++) { $a->lpush('goods',1); } return $this->redirect(array('goods/info')); } else { echo "添加失败"; } } else { return $this->render('add'); } } public function actionOrder() { $redis=yii::$app->redis; $count=$redis->lpop('goods'); if(empty($count)) { echo "库存不足";die; } $res=yii::$app->db->createCommand("update goods set counts=counts-1 where id=1 and counts>0")->execute(); if($res) { echo "秒杀成功"; } else { echo "秒杀失败"; } } } ?>
植物大战僵尸抽卡版在哪里下载-植物大战僵尸抽卡版下载地址分享
植物大战僵尸融合版v2.2版本在哪下载-v2.2版本下载地址分享
黑神话悟空像素版0.3版本在哪下载-0.3版本下载地址分享
黑神话悟空像素版0.4版本在哪下载-像素黑神话0.4版本下载地址分享
燕云十六声梨园和醉花阴怎么选-梨园和醉花阴选择推荐
Sensor Tower 数据显示《棕色尘埃 2》于台湾、香港登上营收排行第一名 每日活跃用户创新高