| @@ 835-841 (lines=7) @@ | ||
| 832 | // If the w parameter is set to acknowledge the write, |
|
| 833 | // returns an associative array with the status of the inserts ("ok") |
|
| 834 | // and any error that may have occurred ("err"). |
|
| 835 | if(is_array($result)) { |
|
| 836 | if($result['ok'] != 1) { |
|
| 837 | throw new Exception('Batch insert error: ' . $result['err']); |
|
| 838 | } |
|
| 839 | ||
| 840 | return $this; |
|
| 841 | } |
|
| 842 | ||
| 843 | // Otherwise, returns TRUE if the batch insert was successfully sent, |
|
| 844 | // FALSE otherwise. |
|
| @@ 908-913 (lines=6) @@ | ||
| 905 | ); |
|
| 906 | ||
| 907 | // if write concern acknowledged |
|
| 908 | if(is_array($result)) { |
|
| 909 | if($result['ok'] != 1) { |
|
| 910 | throw new Exception(sprintf('Update error: %s: %s', $result['err'], $result['errmsg'])); |
|
| 911 | } |
|
| 912 | return $this; |
|
| 913 | } |
|
| 914 | ||
| 915 | // if write concern unacknowledged |
|
| 916 | if(!$result) { |
|
| @@ 883-889 (lines=7) @@ | ||
| 880 | $result = $targetMongoCollection->batchInsert($documentList); |
|
| 881 | ||
| 882 | // check result |
|
| 883 | if(is_array($result)) { |
|
| 884 | if($result['ok'] != 1) { |
|
| 885 | throw new Exception('Batch insert error: ' . $result['err']); |
|
| 886 | } |
|
| 887 | } elseif(!$result) { |
|
| 888 | throw new Exception('Batch insert error'); |
|
| 889 | } |
|
| 890 | } |
|
| 891 | ||
| 892 | return $this; |
|