5use InvalidArgumentException;
6use UnexpectedValueException;
35 private $caller = __CLASS__;
40 private $uniqueIndexFields = [];
60 if ( $this->db->getType() !==
$db->
getType() ) {
61 throw new InvalidArgumentException(
62 __METHOD__ .
' cannot switch to a database of a different type.'
85 if ( isset( $info[
'table'] ) ) {
86 $this->
table( $info[
'table'] );
88 if ( isset( $info[
'rows'] ) ) {
89 $this->
rows( $info[
'rows'] );
91 if ( isset( $info[
'uniqueIndexFields'] ) ) {
94 if ( isset( $info[
'caller'] ) ) {
95 $this->
caller( $info[
'caller'] );
108 $this->
table = $table;
120 return $this->
table( $table );
133 public function rows( array $rows ) {
134 $this->
rows = array_merge( $this->
rows, $rows );
147 public function row( array $row ) {
148 $this->
rows[] = $row;
159 if ( is_string( $uniqueIndexFields ) ) {
160 $uniqueIndexFields = [ $uniqueIndexFields ];
182 if ( !$this->
rows ) {
183 throw new UnexpectedValueException(
184 __METHOD__ .
' can\'t have empty $rows value' );
186 if ( $this->
table ===
'' ) {
187 throw new UnexpectedValueException(
188 __METHOD__ .
' expects table not to be empty' );
191 throw new UnexpectedValueException(
192 __METHOD__ .
' expects unique key to be provided' );
209 'table' => $this->table,
210 'rows' => $this->rows,
211 'uniqueIndexFields' => $this->uniqueIndexFields,
213 if ( $this->
caller !== __CLASS__ ) {
214 $info[
'caller'] = $this->caller;