zoukankan      html  css  js  c++  java
  • yii2.0 的数据的 增

    增加数据

        /**
         * 添加数据  controller 层
         */

      //引入对应的model类

      use appmodelsAbout;

      //定义对应的方法固定的actionxxxx -- 增加数据

      public function actionAdd(){

            //判断是否是提交过来的数据

            $request = Yii::$app->request;

            if ($request->isPost){

                    //实力话model

                $model_about = new About();

                $model_ok = $model_about->adddata();

                if ($model_ok) {

                    //添加成功 跳转到 index 方法
                    
                    return $this->redirect(Url::toRoute('/about/index'));

                    exit;

                }
            }

            //添加数据

            return $this->renderPartial('add');
        }

        /**
         * 添加数据  models层
         */

        public function adddata(){

                //接收数据

            $this->about_name = trim($_POST['about_name']);
            $this->about_link = trim($_POST['about_link']);
            $this->about_num = trim($_POST['about_num']);
            $this->about_show = trim($_POST['about_show']);
            $this->about_status = trim($_POST['about_status']);        

            return $this->save();
        }

  • 相关阅读:
    2021软工-提问回顾与个人总结
    2021软工-调研作业-Notion
    2021年软工-个人阅读作业2
    tester
    tableau学做两个集合的维恩图(文氏图)Venn diagram 二维文氏图
    python学习
    pv操作是否会造成死锁呢?
    提问的正确姿势
    【BUAA OO Unit3】史上最全OpenJML摸索实录
    MVC和三层架构的区别
  • 原文地址:https://www.cnblogs.com/laowenBlog/p/5280418.html
Copyright © 2011-2022 走看看