首页 > Web开发 > 详细

thinkphp笔记

时间:2015-11-18 14:10:36      阅读:326      评论:0      收藏:0      [点我收藏+]

 

<?php
// 本类由系统自动生成,仅供测试用途
class IndexAction extends Action {
  /**
  首页视图 */
    public function index(){
	//echo "这是我的前台应用首页";
  //  $user = M(‘user‘)->select();
     $this->assign(‘user‘,M(‘user‘)->select())->display();//将user表中内容全部查询出来,赋给模板
    //$this->a = ‘dazhangdi‘; //单个赋值
//	$this->display();
	//echo U(‘Index/index‘, array(‘aid‘ => 1, ‘uid‘ => 10), ‘htm‘); ///index.php/Index/index.html    /index.php?m=Index&a=index&aid=1&uid=10    array()里面传递参数   
   //U函数生成页面地址,可加参数
      
    }
    
    public function handle(){
/**
表单视图
*/
   //    $username = $this->_post(‘username‘);
//     echo $username;
   if (!IS_POST)  _404(‘页面不存在‘,U(‘index‘));
    // $username = I(‘username‘); //获取POST参数值。但是不会过过滤脚本
//       // $username = I(‘username‘,‘默认内容‘,‘htmlspecialchars‘); 
//       echo $username;
   $data = array(
        ‘username‘ => I(‘username‘,‘‘,‘htmlspecialchars‘),
    ‘content‘ => I(‘content‘,‘‘,‘htmlspecialchars‘),
    ‘time‘ => time()
   );    
   
//   $result = M(‘user‘)->where(‘id > 1‘)->delete();  //删除id>1的信息
//   var_dump($result);//返回受影响的数目
  if( M(‘user‘)->data($data)->add()){
    $this->success(‘发布成功‘,‘index‘);
     
  }else{
     $this->error(‘发布失败......‘);
   }
   
   
    
   
    }
      
         
    }
    

  

thinkphp笔记

原文:http://www.cnblogs.com/xtmp/p/4974119.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!