XF 2.1 Database Master/Slave - Read query from Master?

Well, if you have a master / slave setup and specify the database servers in your config.php, then all SELECT queries should be automatically fetched from the slave server. So, I ask if there's some code to force a read form the master (for time critical queries).
 
Looked a bit around. Can I do something like this?

PHP:
$db = \XF->app()->db();

if ($db instanceof \XF\Db\ReplicationAdapterInterface)
{
    $db->forceToWriteServer(true);
}
// from now on all queries are sent to the database master server during run time.

I also saw that I can use a "modifier" like -- XFDB=fromWrite at the beginning of the query. But I guess that's only possible with raw sql.. 🤔
 
Last edited:
Top Bottom