5use InvalidArgumentException;
6use UnexpectedValueException;
43 private $caller = __CLASS__;
71 if ( $this->db->getType() !==
$db->
getType() ) {
72 throw new InvalidArgumentException(
73 __METHOD__ .
' cannot switch to a database of a different type.'
97 if ( isset( $info[
'table'] ) ) {
98 $this->
table( $info[
'table'] );
100 if ( isset( $info[
'set'] ) ) {
101 $this->
set( $info[
'set'] );
103 if ( isset( $info[
'conds'] ) ) {
104 $this->
where( $info[
'conds'] );
106 if ( isset( $info[
'options'] ) ) {
107 $this->
options( (array)$info[
'options'] );
109 if ( isset( $info[
'caller'] ) ) {
110 $this->
caller( $info[
'caller'] );
123 $this->
table = $table;
134 public function update(
string $table ) {
135 return $this->
table( $table );
146 public function option( $name, $value =
null ) {
147 if ( $value ===
null ) {
150 $this->
options[$name] = $value;
205 if ( is_array( $conds ) ) {
206 foreach ( $conds as $key => $cond ) {
207 if ( is_int( $key ) ) {
208 $this->
conds[] = $cond;
209 } elseif ( isset( $this->
conds[$key] ) ) {
212 $this->
conds[] = $this->db->makeList(
215 $this->
conds[$key] = $cond;
219 $this->
conds[] = $conds;
232 return $this->
where( $conds );
243 return $this->
where( $conds );
268 public function set( $set ) {
269 if ( is_array( $set ) ) {
270 foreach ( $set as $key => $value ) {
271 if ( is_int( $key ) ) {
272 $this->
set[] = $value;
274 $this->
set[$key] = $value;
291 return $this->
set( $set );
324 throw new UnexpectedValueException(
325 __METHOD__ .
' expects at least one condition to be set' );
328 throw new UnexpectedValueException(
329 __METHOD__ .
' can\t have empty $set value' );
331 if ( $this->
table ===
'' ) {
332 throw new UnexpectedValueException(
333 __METHOD__ .
' expects table not to be empty' );
351 'table' => $this->table,
353 'conds' => $this->conds,
354 'options' => $this->options,
356 if ( $this->caller !== __CLASS__ ) {
357 $info[
'caller'] = $this->caller;
if(!defined('MW_SETUP_CALLBACK'))