返回URL_JSO......登陆

URL_JSON番外篇

郑延东2019-03-22 13:13:13189

<?php


namespace app\index\controller;
use think\Collection;
use think\Db;
use think\db\Query;

class Test1 extends Collection
{
   //数据库连接测试 静态连接,动态连接,环境变量连接,模型连接
   public function demo1(){
       //静态连接 database.php
       $res=Db::table('staff')->limit(1)->select();

       //动态连接 database.php 'my_db'
       $res=Db::connect('my_db')
           ->table('staff')
           ->limit(2)
           ->select();
       //环境变量 类似用户自定义的全局变量,一次定义,都能用,定义.env文件
       $res=Db::table('staff')->limit(3)->select();
       //模型连接
       $res=\app\index\model\Staff::limit(4)->select();


       dump($res);
   }

最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送