<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class Test extends Model
{
// 数据库'database_test'中的test表
public $table = 'test';
public $timestamps = false;
protected $connection = 'mysql_test';
}
model实例(这个model将采用默认的'mysql'连接)
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class Test extends Model
{
// 数据库'database'中的test表
public $table = 'test';
public $timestamps = false;
// 以下代码可有可不、默认连接mysql
protected $connection = 'mysql';
}
a、这个model将采用默认的'mysql'连接
class UserModel extends Model
{
// 数据库'database'中的users表
protected $table = "users";
}
b、