How to utilize the Replica in a Laravel application? #512
-
According to the Laravel documentation (https://laravel.com/docs/10.x/database#read-and-write-connections), I need to determine the database host of the replica. Where can I find this information, and what will happen in the event of a failover? Will the database host switch between the two? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Instructions for how to query a replica are available here: https://planetscale.com/docs/concepts/replicas |
Beta Was this translation helpful? Give feedback.
-
You might look at https://laravel.com/docs/10.x/database#read-and-write-connections . Notice that while commonly only DB_HOST_READER and DB_HOST_WRITER are different, the text suggests that you can separate any of the configuration attributes in that array into values for read and write, including the database. Someone from Customer support at PlanetScale has pointed out to me that the database name @replica works just as well as the USE @replica solution, and that seems to work. |
Beta Was this translation helpful? Give feedback.
-
You can configure in your database.php config file
|
Beta Was this translation helpful? Give feedback.
Instructions for how to query a replica are available here: https://planetscale.com/docs/concepts/replicas