MediaWiki REL1_35
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
61 public function write( array $updates ) {
62 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
63 $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
64
65 foreach ( $updates as $update ) {
66 $this->db->update(
67 $this->table,
68 $update['changes'],
69 $update['primaryKey'],
70 __METHOD__
71 );
72 }
73
74 $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket );
75 }
76}
__construct(IDatabase $db, $table, $clusterName=false)
write(array $updates)
string false $clusterName
A cluster name valid for use with LBFactory.
IDatabase $db
The database to write to.
string $table
The name of the table to update.
MediaWikiServices is the service locator for the application scope of MediaWiki.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38