5use InvalidArgumentException;
6use UnexpectedValueException;
40 private $caller = __CLASS__;
65 if ( $this->db->getType() !==
$db->
getType() ) {
66 throw new InvalidArgumentException(
67 __METHOD__ .
' cannot switch to a database of a different type.'
91 if ( isset( $info[
'table'] ) ) {
92 $this->
table( $info[
'table'] );
94 if ( isset( $info[
'set'] ) ) {
95 $this->
set( $info[
'set'] );
97 if ( isset( $info[
'conds'] ) ) {
98 $this->
where( $info[
'conds'] );
100 if ( isset( $info[
'options'] ) ) {
101 $this->
options( (array)$info[
'options'] );
103 if ( isset( $info[
'caller'] ) ) {
104 $this->
caller( $info[
'caller'] );
117 $this->
table = $table;
128 public function update(
string $table ) {
129 return $this->
table( $table );
140 public function option( $name, $value =
null ) {
141 if ( $value ===
null ) {
144 $this->
options[$name] = $value;
200 if ( is_array( $conds ) ) {
201 foreach ( $conds as $key => $cond ) {
202 if ( is_int( $key ) ) {
203 $this->
conds[] = $cond;
204 } elseif ( isset( $this->
conds[$key] ) ) {
207 $this->
conds[] = $this->db->makeList(
210 $this->
conds[$key] = $cond;
214 $this->
conds[] = $conds;
228 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'))