MediaWiki REL1_34
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}
__construct(IDatabase $db, $table, $clusterName=false)
write(array $updates)
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