select(); $this->assign("mylist",$result); return view("helloworld"); /*查询数据*/ // $map=array( // "status"=" />
牛骨文教育服务平台(让学习变的简单)
博文笔记

thinkphp5 之数据操作和模板输出

创建时间:2016-11-29 投稿人: 浏览次数:3670
       $result=Db::table("ims_ewei_shop_ceshib")->select();
        $this->assign("mylist",$result);
        return view("helloworld");
        /*查询数据*/
         // $map=array(
         //    "status"=>1,
         // );
         // $result=db("ims_ewei_shop_ceshib")->where($map)->select();
         /*添加一条数据*/
         // $insertdata=array(

         //   "name"=>"g",
         //   "age"=>24,
         //   "status"=>1,

         //     );
          /*返回添加成功的条数*/
         // $result=db("ims_ewei_shop_ceshib")->insert($insertdata);
         /*返回新增数据的自增主键*/
         // $userid=db("ims_ewei_shop_ceshib")->insertGetId($insertdata);
        /*添加多条数据*/
//         $muchdata=array(
//                "0"=>array(
//                     "name"=>"h",
//                     "age"=>24,
//                     "status"=>0,
//                          ),
//               "1"=>array(
//                     "name"=>"i",
//                    "age"=>24,
//                    "status"=>1,
//                        ),
//              );
// $res=db("ims_ewei_shop_ceshib")->insertAll($muchdata);

  // /*更新数据*/
  //   $updata=array(
  //     "name"=>"nji",
  //     "age"=>23,
  //    );
  // $map=array(
  //  "id"=>4,
  //    );

  // /*更新数据*/
  //  $res=db("ims_ewei_shop_ceshib")->where($map)->update($updata);
 /*更新某个字段的值*/
//     $fileddata=array(
//   "name"=>"today"
//      );
//   $map=array(
//    "id"=>6,
//      );
// $res=db("ims_ewei_shop_ceshib")->where($map)->setField($fileddata);
 /*给变量赋值要加  	hinkController*/
// $res="helloworld";
//  $this->assign("result",$res);
  /*输出模板*/
  // return view("helloworld");
  // return    $this->fetch("helloworld");

  /*输出模板和变量*/
// return    $this->fetch("helloworld",array("name"=>"ieroe"));
// return    view("helloworld",array("name"=>"aurhpar"));

  /*使用fetch输出模板和变量(变量用数组传值)头部加use thinkview;*/
//  $view = new View();
// return $view->fetch("helloworld",array("name"=>"11111343fff"));
  /*直接显示内容到模板上*/
  // return    $this->display("helloworld");
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。