laravel数据库的使用方法

方法一:

1、php文件开头引入:

use Illuminate\Support\Facades\DB;

use App\Models\Articles;
use App\Models\Category;//使用的数据表名

则可使用如下方法连接到数据库,例:

$articles = DB::table('articles')->join('category','articles.cateid','=','category.id')->get();

posted @ 2017-07-05 10:02  mayer326  阅读(153)  评论(0编辑  收藏  举报