Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
moodle_read_slave_trait.php File Reference

Functions

 can_use_readonly (int $type, string $sql)
 Check if The query qualifies for readonly connection execution Logging queries are exempt, those are write operations that circumvent standard query_start/query_end paths.
 
 commit_delegated_transaction (moodle_transaction $transaction)
 Indicates delegated transaction finished successfully.
 
 connect ($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dboptions=null)
 Connect to db The connection parameters processor that sets up stage for master write and slave readonly handles.
 
 get_db_handle ()
 Gets db handle currently used with queries.
 
 perf_get_reads_slave ()
 Returns the number of reads done by the read only database.
 
 query_end ($result)
 This should be called immediately after each db query.
 
 query_start ($sql, ?array $params, $type, $extrainfo=null)
 Called before each db query.
 
 raw_connect (string $dbhost, string $dbuser, string $dbpass, string $dbname, $prefix, array $dboptions=null)
 Connect to db The real connection establisment, called from connect() and set_dbhwrite()
 
 select_db_handle (int $type, string $sql)
 Select appropriate db handle - readwrite or readonly.
 
 set_db_handle ($dbh)
 Sets db handle to be used with subsequent queries.
 
 start_delegated_transaction ()
 On DBs that support it, switch to transaction mode and begin a transaction.
 
 table_names (string $sql)
 Parse table names from query.
 
 want_read_slave ()
 Returns whether we want to connect to slave database for read queries.
 

Variables

resource $dbhreadonly
 slave read only database handle
 
trait moodle_read_slave_trait
 Trait to wrap connect() method of database driver classes that gives ability to use read only slave instances for SELECT queries.