File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ Laravel 支持 SQL Server 数据库; 无论以何种方式, 您都需要将数
6666 'write' => [
6767 'host' => '196.168.1.2'
6868 ],
69+ 'sticky' => true,
6970 'driver' => 'mysql',
7071 'database' => 'database',
7172 'username' => 'root',
@@ -79,6 +80,10 @@ Laravel 支持 SQL Server 数据库; 无论以何种方式, 您都需要将数
7980
8081你只需要把项目放在 ` read ` 和 ` write ` 数组中,除非你想要覆盖主数组的值。所以,在这种情况下,` 192.168.1.1 ` 将用作「读」连接的主机,而 ` 192.168.1.2 ` 将用于「写」连接。这两个连接会共享在 ` mysql ` 主数组中的配置。如:数据库的凭证,前缀,字符集,以及其他的选项。
8182
83+ ** ` sticky ` 选项**
84+
85+ ` sticky ` 是一个可选的选项,它的具体作用是:若在当前的请求周期内,数据库曾经被写入过一些数据,` sticky ` 选项会立即将这些数据读出来。如果 ` sticky ` 选项是 ` true ` ,而且在当前的请求周期内对数据看执行过 ”写入“ 操作,那么任何 "读取" 的操作都会使用「写」连接。这使得任何在同一请求周期写入的数据都会被立刻读取。这个取决于这个选项的作用是否符合你的程序的期望。
86+
8287<a name =" using-multiple-database-connections " ></a >
8388
8489### 使用多个数据库连接
@@ -251,4 +256,4 @@ Laravel 支持 SQL Server 数据库; 无论以何种方式, 您都需要将数
251256>
252257> 转载请注明:本文档由 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 ) 。
253258>
254- > 文档永久地址: https://d.laravel-china.org
259+ > 文档永久地址: https://d.laravel-china.org
You can’t perform that action at this time.
0 commit comments