5use InvalidArgumentException;
6use UnexpectedValueException;
35 private $caller = __CLASS__;
40 private $uniqueIndexFields = [];
56 if ( $this->db->getType() !==
$db->
getType() ) {
57 throw new InvalidArgumentException(
58 __METHOD__ .
' cannot switch to a database of a different type.'
69 if ( isset( $info[
'table'] ) ) {
70 $this->
table( $info[
'table'] );
72 if ( isset( $info[
'rows'] ) ) {
73 $this->
rows( $info[
'rows'] );
75 if ( isset( $info[
'uniqueIndexFields'] ) ) {
78 if ( isset( $info[
'caller'] ) ) {
79 $this->
caller( $info[
'caller'] );
91 public function table( $table ) {
92 $this->
table = $table;
104 return $this->
table( $table );
117 public function rows( array $rows ) {
118 $this->
rows = array_merge( $this->
rows, $rows );
131 public function row( array $row ) {
132 $this->
rows[] = $row;
143 if ( is_string( $uniqueIndexFields ) ) {
144 $uniqueIndexFields = [ $uniqueIndexFields ];
163 throw new UnexpectedValueException(
164 __METHOD__ .
' can\'t have empty $rows value' );
166 if ( $this->
table ===
'' ) {
167 throw new UnexpectedValueException(
168 __METHOD__ .
' expects table not to be empty' );
171 throw new UnexpectedValueException(
172 __METHOD__ .
' expects unique key to be provided' );
182 'table' => $this->table,
183 'rows' => $this->rows,
184 'uniqueIndexFields' => $this->uniqueIndexFields,
186 if ( $this->caller !== __CLASS__ ) {
187 $info[
'caller'] = $this->caller;
if(!defined('MW_SETUP_CALLBACK'))