$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);
/*给变量赋值要加 \think\Controller*/
// $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 think\view;*/
// $view = new View();
// return $view->fetch('helloworld',array('name'=>'11111343fff'));
/*直接显示内容到模板上*/
// return $this->display('helloworld');
thinkphp5 之数据操作和模板输出
最新推荐文章于 2024-07-22 09:56:56 发布