5use InvalidArgumentException;
6use UnexpectedValueException;
35 private $caller = __CLASS__;
40 private $uniqueIndexFields = [];
61 if ( $this->db->getType() !==
$db->
getType() ) {
62 throw new InvalidArgumentException(
63 __METHOD__ .
' cannot switch to a database of a different type.'
86 if ( isset( $info[
'table'] ) ) {
87 $this->
table( $info[
'table'] );
89 if ( isset( $info[
'rows'] ) ) {
90 $this->
rows( $info[
'rows'] );
92 if ( isset( $info[
'uniqueIndexFields'] ) ) {
95 if ( isset( $info[
'caller'] ) ) {
96 $this->
caller( $info[
'caller'] );
109 $this->
table = $table;
121 return $this->
table( $table );
134 public function rows( array $rows ) {
135 $this->
rows = array_merge( $this->
rows, $rows );
148 public function row( array $row ) {
149 $this->
rows[] = $row;
160 if ( is_string( $uniqueIndexFields ) ) {
161 $uniqueIndexFields = [ $uniqueIndexFields ];
183 if ( !$this->
rows ) {
184 throw new UnexpectedValueException(
185 __METHOD__ .
' can\'t have empty $rows value' );
187 if ( $this->
table ===
'' ) {
188 throw new UnexpectedValueException(
189 __METHOD__ .
' expects table not to be empty' );
192 throw new UnexpectedValueException(
193 __METHOD__ .
' expects unique key to be provided' );
210 'table' => $this->table,
211 'rows' => $this->rows,
212 'uniqueIndexFields' => $this->uniqueIndexFields,
214 if ( $this->
caller !== __CLASS__ ) {
215 $info[
'caller'] = $this->caller;