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}
  • 相关阅读:
    DAY 169 创建虚拟环境05
    DAY 168 创建虚拟环境04
    DAY 167 创建虚拟环境03
    DAY 166 创建虚拟环境02
    java 内存区域
    java 内存机制
    JAVA GC
    JAVA根搜索算法
    mysql ---事务
    java lock -----锁
  • 原文地址:https://www.cnblogs.com/Crius/p/thinkphp.html
Copyright © 2011-2022 走看看