5 use InvalidArgumentException;
6 use 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.'
93 if ( isset( $info[
'table'] ) ) {
94 $this->
table( $info[
'table'] );
96 if ( isset( $info[
'set'] ) ) {
97 $this->
set( $info[
'set'] );
99 if ( isset( $info[
'conds'] ) ) {
100 $this->
where( $info[
'conds'] );
102 if ( isset( $info[
'options'] ) ) {
103 $this->
options( (array)$info[
'options'] );
115 $this->
table = $table;
125 public function update(
string $table ) {
126 return $this->
table( $table );
137 public function option( $name, $value =
null ) {
138 if ( $value ===
null ) {
141 $this->
options[$name] = $value;
195 if ( is_array( $conds ) ) {
196 foreach ( $conds as $key => $cond ) {
197 if ( is_int( $key ) ) {
198 $this->
conds[] = $cond;
199 } elseif ( isset( $this->
conds[$key] ) ) {
202 $this->
conds[] = $this->db->makeList(
205 $this->
conds[$key] = $cond;
209 $this->
conds[] = $conds;
221 return $this->
where( $conds );
231 return $this->
where( $conds );
255 public function set( $set ) {
256 if ( is_array( $set ) ) {
257 foreach ( $set as $key => $value ) {
258 if ( is_int( $key ) ) {
259 $this->
set[] = $value;
261 $this->
set[$key] = $value;
277 return $this->
set( $set );
310 if ( !$this->
conds ) {
311 throw new UnexpectedValueException(
312 __METHOD__ .
' expects at least one condition to be set' );
315 throw new UnexpectedValueException(
316 __METHOD__ .
' can\t have empty $set value' );
318 if ( $this->
table ===
'' ) {
319 throw new UnexpectedValueException(
320 __METHOD__ .
' expects table not to be empty' );
337 'table' => $this->table,
339 'conds' => $this->conds,