db\Connection useMaster()

useMaster() public method

Executes the provided callback by using the master connection.

This method is provided so that you can temporarily force using the master connection to perform DB operations even if they are read queries. For example,

$result = $db->useMaster(function ($db) {
    return $db->createCommand('SELECT * FROM user LIMIT 1')->queryOne();
});
public mixed useMaster ( callable $callback )
$callback callable

A PHP callable to be executed by this method. Its signature is function (Connection $db). Its return value will be returned by this method.

return mixed

The return value of the callback

doc_Yii
2016-10-30 16:57:52
Comments
Leave a Comment

Please login to continue.