MediaWiki  1.34.0
BatchRowWriter.php
Go to the documentation of this file.
1 <?php
26 
31  protected $db;
32 
36  protected $table;
37 
41  protected $clusterName;
42 
48  public function __construct( IDatabase $db, $table, $clusterName = false ) {
49  $this->db = $db;
50  $this->table = $table;
51  $this->clusterName = $clusterName;
52  }
53 
60  public function write( array $updates ) {
61  $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
62  $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
63 
64  foreach ( $updates as $update ) {
65  $this->db->update(
66  $this->table,
67  $update['changes'],
68  $update['primaryKey'],
69  __METHOD__
70  );
71  }
72 
73  $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket );
74  }
75 }
BatchRowWriter\$table
$table
Definition: BatchRowWriter.php:36
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:117
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
BatchRowWriter\write
write(array $updates)
Definition: BatchRowWriter.php:60
BatchRowWriter\__construct
__construct(IDatabase $db, $table, $clusterName=false)
Definition: BatchRowWriter.php:48
BatchRowWriter
Definition: BatchRowWriter.php:27
BatchRowWriter\$db
$db
Definition: BatchRowWriter.php:31
BatchRowWriter\$clusterName
$clusterName
Definition: BatchRowWriter.php:41