File tree 1 file changed +6
-1
lines changed
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ Laravel 支持 SQL Server 数据库; 无论以何种方式, 您都需要将数
66
66
'write' => [
67
67
'host' => '196.168.1.2'
68
68
],
69
+ 'sticky' => true,
69
70
'driver' => 'mysql',
70
71
'database' => 'database',
71
72
'username' => 'root',
@@ -79,6 +80,10 @@ Laravel 支持 SQL Server 数据库; 无论以何种方式, 您都需要将数
79
80
80
81
你只需要把项目放在 ` read ` 和 ` write ` 数组中,除非你想要覆盖主数组的值。所以,在这种情况下,` 192.168.1.1 ` 将用作「读」连接的主机,而 ` 192.168.1.2 ` 将用于「写」连接。这两个连接会共享在 ` mysql ` 主数组中的配置。如:数据库的凭证,前缀,字符集,以及其他的选项。
81
82
83
+ ** ` sticky ` 选项**
84
+
85
+ ` sticky ` 是一个可选的选项,它的具体作用是:若在当前的请求周期内,数据库曾经被写入过一些数据,` sticky ` 选项会立即将这些数据读出来。如果 ` sticky ` 选项是 ` true ` ,而且在当前的请求周期内对数据看执行过 ”写入“ 操作,那么任何 "读取" 的操作都会使用「写」连接。这使得任何在同一请求周期写入的数据都会被立刻读取。这个取决于这个选项的作用是否符合你的程序的期望。
86
+
82
87
<a name =" using-multiple-database-connections " ></a >
83
88
84
89
### 使用多个数据库连接
@@ -251,4 +256,4 @@ Laravel 支持 SQL Server 数据库; 无论以何种方式, 您都需要将数
251
256
>
252
257
> 转载请注明:本文档由 Laravel China 社区 [ laravel-china.org] ( https://laravel-china.org ) 组织翻译,详见 [ 翻译召集帖] ( https://laravel-china.org/topics/5756/laravel-55-document-translation-call-come-and-join-the-translation ) 。
253
258
>
254
- > 文档永久地址: https://d.laravel-china.org
259
+ > 文档永久地址: https://d.laravel-china.org
You can’t perform that action at this time.
0 commit comments