| @@ 829-835 (lines=7) @@ | ||
| 826 | // If the w parameter is set to acknowledge the write, |
|
| 827 | // returns an associative array with the status of the inserts ("ok") |
|
| 828 | // and any error that may have occurred ("err"). |
|
| 829 | if(is_array($result)) { |
|
| 830 | if($result['ok'] != 1) { |
|
| 831 | throw new Exception('Batch insert error: ' . $result['err']); |
|
| 832 | } |
|
| 833 | ||
| 834 | return $this; |
|
| 835 | } |
|
| 836 | ||
| 837 | // Otherwise, returns TRUE if the batch insert was successfully sent, |
|
| 838 | // FALSE otherwise. |
|
| @@ 902-907 (lines=6) @@ | ||
| 899 | ); |
|
| 900 | ||
| 901 | // if write concern acknowledged |
|
| 902 | if(is_array($result)) { |
|
| 903 | if($result['ok'] != 1) { |
|
| 904 | throw new Exception(sprintf('Update error: %s: %s', $result['err'], $result['errmsg'])); |
|
| 905 | } |
|
| 906 | return $this; |
|
| 907 | } |
|
| 908 | ||
| 909 | // if write concern unacknowledged |
|
| 910 | if(!$result) { |
|
| @@ 901-907 (lines=7) @@ | ||
| 898 | $result = $targetMongoCollection->batchInsert($documentList); |
|
| 899 | ||
| 900 | // check result |
|
| 901 | if(is_array($result)) { |
|
| 902 | if($result['ok'] != 1) { |
|
| 903 | throw new Exception('Batch insert error: ' . $result['err']); |
|
| 904 | } |
|
| 905 | } elseif(!$result) { |
|
| 906 | throw new Exception('Batch insert error'); |
|
| 907 | } |
|
| 908 | } |
|
| 909 | ||
| 910 | return $this; |
|