zoukankan      html  css  js  c++  java
  • ThinkPHP 3.2.3

    说明手册
    https://www.kancloud.cn/manual/thinkphp/1706

    下载地址
    https://gitee.com/liu21st/thinkphp32

    thinkPHP 3.2.3 是从showdoc开源项目里面看到的,最新版的TP比较复杂,先看看这个老版本的。
    https://www.showdoc.com.cn/help?page_id=4087044677189279

    前台访问地址:
    http://localhost:8033/server/index.php/Home/Index/index

    数据库配置:
    ApplicationCommonConfconfig.php

    <?php
    return array(  
    	'DB_TYPE'=> 'mysql',  
    	'DB_HOST'=> 'localhost',  
    	'DB_NAME'=>'think_list',  
    	'DB_USER'=>'root',  
    	'DB_PWD'=>'123456',  
    	'DB_PORT'=>'3306',  
    	'DB_PREFIX'=>'think_',  
    	);  
    

    第一个 Controller
    ApplicationHomeControllerIndexController.class.php

    <?php
    namespace HomeController;
    
    use ThinkController;
    
    class IndexController extends Controller
    {
        public function index()
        {
            $List = D("List");
            echo json_encode($List->select());
        }
    }
    

    BaseController.class.php

    <?php
    
    
    namespace HomeController;
    use ThinkController;
    
    class BaseController extends Controller
    {
        /**
         * 返回json结果
         */
        protected function sendResult($array){
            if (isset($array['error_code'])) {
                $result['error_code'] = $array['error_code'] ;
                $result['error_message'] = $array['error_message'] ;
            }
            else{
                $result['error_code'] = 0 ;
                $result['data'] = $array ;
            }
    
            if ($this->is_local_debug > 0 ) {
                header('Access-Control-Allow-Origin: *');//允许跨域请求
                header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Connection, User-Agent, Cookie');
                header('Access-Control-Allow-Credentials: true');//允许跨域请求
            }
    
            echo json_encode($result);
    
            //如果开启API调试模式,则记录请求参数和返回结果
            if (C('API_LOG')) {
                $info = '';
                $info .= "
    
    【★★★★★★★★★★★】";
                $info .= "
    请求接口:".MODULE_NAME  ."/".CONTROLLER_NAME."/".ACTION_NAME."";
                $info .= "
    请求".'$_REQUEST'.":
    ";
                $info .= json_encode($_REQUEST);
                $info .= "
    返回结果:
    ";
                $info .= json_encode($result)."
    ";
                $info .= "【★★★★★★★★★★★】
    ";
                Thinklog::record($info , 'INFO');
            }
    
        }
    }
    

    ListController.class.php

    
    <?php
    namespace HomeController;
    class ListController extends BaseController
    {
        public function list()
        {
            $List = D("List"); // 实例化User对象
            $this->sendResult($List->select());
        }
    
        public function insert() {
            $insert = array(
                "text" => '123' ,
                "status" => '111'
            );
            $List = D("List")->add($insert);
            $result = array(
                "tip" => 'ok'
            );
            $this->sendResult($result);
        }
    
        public function update() {
            D("List")->where("id='1'")->save(array('text'=>'text111'));
            $this->sendResult(array('tip'=>"ok"));
        }
    }
    
    

    php token 的获取

    $headers = getallheaders();
    dump($headers["Token"]);
    
    ---------------------------------------------
    生活的意义并不是与他人争高下,而在于享受努力实现目标的过程,结果是对自己行动的嘉奖。
    ↑面的话,越看越不痛快,应该这么说:

    生活的意义就是你自己知道你要做什么,明确目标。没有目标,后面都是瞎扯!
  • 相关阅读:
    JQ-动画合集(ing...)
    CSS-各种cs样式之浏览器兼容处理方式汇总大全(更新中...)
    CSS-用伪元素制作小箭头(轮播图的左右切换btn)
    CSS-垂直|水平居中问题的解决方法总结
    JS-自制提速小工具:开发页面时需要按比例计算宽高值的快速计算器
    canvas-渐变文字
    HTML-一个网页的头部的大概框架(完善ing)
    JS-面向对象
    CSS-border属性制作小三角
    JS事件-事件处理程序-笔记总结ing...
  • 原文地址:https://www.cnblogs.com/pengchenggang/p/14367042.html
Copyright © 2011-2022 走看看