### 使用 model 强制获取主库数据
```
AMode::onWriteConnect()->get();
```
### 使用 DB 方法获取主库数据
- 方法一:
```
DB::table('a')->lock()->get();
```
- 方法二:
```
$sql = 'select * from a';
DB::select($sql, [], false);
```
- 方法三:
```
#在 config/database.php 配置文件里面配置读库
'write' => [
'driver' => 'mysql',
'host' => env('DB_WRITE_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
#手动链接主库查询
DB::connection('write')->table('a')->get();
```
- 方法四(仅供参考):
```
$pdo = DB::connection()->getPdo();
$data=DB::connection()->setPdo($pdo)->table('a')->get();
```
- 方法五:
```
$sql = 'select * from a';
DB::selectFromWriteConnection($sql);
```