5use InvalidArgumentException;
6use UnexpectedValueException;
40 private $caller = __CLASS__;
68 if ( $this->db->getType() !==
$db->
getType() ) {
69 throw new InvalidArgumentException(
70 __METHOD__ .
' cannot switch to a database of a different type.'
94 if ( isset( $info[
'table'] ) ) {
95 $this->
table( $info[
'table'] );
97 if ( isset( $info[
'set'] ) ) {
98 $this->
set( $info[
'set'] );
100 if ( isset( $info[
'conds'] ) ) {
101 $this->
where( $info[
'conds'] );
103 if ( isset( $info[
'options'] ) ) {
104 $this->
options( (array)$info[
'options'] );
106 if ( isset( $info[
'caller'] ) ) {
107 $this->
caller( $info[
'caller'] );
120 $this->
table = $table;
131 public function update(
string $table ) {
132 return $this->
table( $table );
143 public function option( $name, $value =
null ) {
144 if ( $value ===
null ) {
147 $this->
options[$name] = $value;
202 if ( is_array( $conds ) ) {
203 foreach ( $conds as $key => $cond ) {
204 if ( is_int( $key ) ) {
205 $this->
conds[] = $cond;
206 } elseif ( isset( $this->
conds[$key] ) ) {
209 $this->
conds[] = $this->db->makeList(
210 [ $key => $cond ], IDatabase::LIST_AND );
212 $this->
conds[$key] = $cond;
216 $this->
conds[] = $conds;
229 return $this->
where( $conds );
240 return $this->
where( $conds );
265 public function set( $set ) {
266 if ( is_array( $set ) ) {
267 foreach ( $set as $key => $value ) {
268 if ( is_int( $key ) ) {
269 $this->
set[] = $value;
271 $this->
set[$key] = $value;
288 return $this->
set( $set );
321 throw new UnexpectedValueException(
322 __METHOD__ .
' expects at least one condition to be set' );
325 throw new UnexpectedValueException(
326 __METHOD__ .
' can\t have empty $set value' );
328 if ( $this->
table ===
'' ) {
329 throw new UnexpectedValueException(
330 __METHOD__ .
' expects table not to be empty' );
348 'table' => $this->table,
350 'conds' => $this->conds,
351 'options' => $this->options,
353 if ( $this->caller !== __CLASS__ ) {
354 $info[
'caller'] = $this->caller;
if(!defined('MW_SETUP_CALLBACK'))