5use InvalidArgumentException;
6use UnexpectedValueException;
35 private $caller = __CLASS__;
40 private $uniqueIndexFields = [];
63 if ( $this->db->getType() !==
$db->
getType() ) {
64 throw new InvalidArgumentException(
65 __METHOD__ .
' cannot switch to a database of a different type.'
88 if ( isset( $info[
'table'] ) ) {
89 $this->
table( $info[
'table'] );
91 if ( isset( $info[
'rows'] ) ) {
92 $this->
rows( $info[
'rows'] );
94 if ( isset( $info[
'uniqueIndexFields'] ) ) {
97 if ( isset( $info[
'caller'] ) ) {
98 $this->
caller( $info[
'caller'] );
111 $this->
table = $table;
123 return $this->
table( $table );
136 public function rows( array $rows ) {
137 $this->
rows = array_merge( $this->
rows, $rows );
150 public function row( array $row ) {
151 $this->
rows[] = $row;
162 if ( is_string( $uniqueIndexFields ) ) {
163 $uniqueIndexFields = [ $uniqueIndexFields ];
185 if ( !$this->
rows ) {
186 throw new UnexpectedValueException(
187 __METHOD__ .
' can\'t have empty $rows value' );
189 if ( $this->
table ===
'' ) {
190 throw new UnexpectedValueException(
191 __METHOD__ .
' expects table not to be empty' );
194 throw new UnexpectedValueException(
195 __METHOD__ .
' expects unique key to be provided' );
212 'table' => $this->table,
213 'rows' => $this->rows,
214 'uniqueIndexFields' => $this->uniqueIndexFields,
216 if ( $this->
caller !== __CLASS__ ) {
217 $info[
'caller'] = $this->caller;