ThinkPHP常用方法

1、在window下,下载框架http://www.thinkphp.cn/down.html

2、解压文件,放置在www目录

3、文件地址http://localhost/thinkphp/public/

4、打开调试窗口application->config.php  'app_debug'              => true

5、模板加载use think\Controller;     配置继承Index extends Controller                $this->fetch();

6、url书写方式 {:url('控制器名字/方法名字')}  eg:{:url('index/test')}  引入use think\Request;

7、获取参数https://www.kancloud.cn/manual/thinkphp5/118042   Request::instance() -> param('title')

8、数据库连接use think\Db;

插入数据

$db = Db::name('user');
        $res = $db->insert([
            'email'    => 'imooc_02',
            'password' => md5('imooc_02'),
            'username' => 'imooc_02',
        ]);

查询

 

$result = Db::query("select * from dsj where user_name='$user' and user_pass='$pass' ");

更新

Db::table('think_user')->where('id', 1)->update(['name' => 'thinkphp']);

删除

Db::execute("delete from user where email ='thinkphp'");

cookie设置

cookie(‘name’,'value',30*60);

cookie获取

cookie(‘name值’)

cookie删除

cookie('name',null)

 

书写ajax步骤

<script src="/js/jquery.min.js"></script>
        <script>
            $('p').click(function(){
                $.ajax({
                    url:"{:url('my/my')}",
                    method:'post',
                    data:{
                        user:'user'
                    },
                    success:function(res){
                        console.log(res);
                    }
                })
            })
        </script>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值