分类:PHP记事本 发布时间:2017-05-30 10:39:44 阅读: 作者:郑祥景
一、/config/database.php 文件添加:
'调用名称' => [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'laravel',
'username' => 'root',
'password' => '******',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
二、在app/Http/model新建AdminModel.php文件(范例而已):
<?php
namespace App\Http\Model;
use Illuminate\Database\Eloquent\Model;
use \Illuminate\Support\Facades\DB;
class AdminModel extends Model{
protected $connect = 'shiyan';
protected $table = 'zy_node';
public $timestamps = false;
public function zidingyi(){
$database = DB::connection($this->connect);
$data = $database->table($this->table)->where('id',11)->get();
return $data;
}
}
编辑:郑祥景