zoukankan      html  css  js  c++  java
  • thinkphp笔记

    1,thinkphp框架修改值方法
    $info = D('biao')->where('lie = '.$bianliang)->setfield('lie',$bianliang);

    2,db操作log

    ThinkPHP/Library/Think/Db.class.php 中update和delete等(除了insert)中加入

     $userlog = M("useroplog");

    $log = '';

    $userlog->add($ar);

    3,tp3.2自定义成功出错方法

        public function success1($info,$url=''){
               $data['info']=$info;
               $data['status']=1;
               $data['url']=$url;
               echo  json_encode($data);
               die;
        }
        public function error1($info,$url=''){
                $data['info']=$info;
                $data['status']=0;
                $data['url']=$url;
                echo  json_encode($data);
            die;
        }
    

      

    4,Contrlller.class.php构造方法中加入验证

            //验证
            $now_c = CONTROLLER_NAME;
            $now_a = ACTION_NAME;
            if(empty($_SESSION['usession'])  ) {
                if($now_c!='Signin' ){
                  if( $now_c != 'Index' && $now_a != 'index') {
                    die("error!");
                  }
                }
            }

    5,异步提交代码

    <script type="text/javascript" src="/public/js/layer/layer.js"></script>
    //head中引入layer.js
    
    {literal}//smarty模板原样输出要加上这个
    <script>
        $('#submit').click(function(){
            var name = $("#admin_user").val();
            var pwd = $("#admin_psd").val();
            if(name.length>2){
                if(pwd.length>0){
                    $.post("/index.php/Admin/login",$("#reg-form").serialize(),function(res){
                        if(res.status==0){
                            layer.msg(res.info,{icon:2})
                        }else{
                            layer.msg('登录成功',{icon:1},function(){
                            location.href="/index.php/Admin/index";
                            })
                        }
                    },'json')
    
                }else{
                    layer.msg('密码不能为空',{icon:2})
                }
    
            }else{
                layer.msg('账号格式不正确至少三个字符',{icon:2});
            }
        })
    </script>
    {/literal}
  • 相关阅读:
    软件测试-三角形问题
    软件测试经典问题——佣金问题
    Ubuntu下ssh免password登录安装
    elasticsearch的javaAPI之query
    非递归实现树的遍历
    递归输出字符串 经典中的经典
    对二维数据进行边界拓展
    【Bootstrap3.0建站笔记一】表单元素排版
    java模拟实现生产者---消费者问题
    Codeforces Round #271 (Div. 2)
  • 原文地址:https://www.cnblogs.com/Crius/p/thinkphp.html
Copyright © 2011-2022 走看看