Commit bb17999f authored by Hannes Magnusson's avatar Hannes Magnusson

improve throw/catch frequency

parent f5619622
...@@ -24,6 +24,16 @@ $bobby = array( ...@@ -24,6 +24,16 @@ $bobby = array(
"nick" => "Bobby Fischer", "nick" => "Bobby Fischer",
"citizen" => "USA", "citizen" => "USA",
); );
$kasparov = array(
"name" => "Garry Kimovich Kasparov",
"nick" => "Kasparov",
"citizen" => "Russia",
);
$spassky = array(
"name" => "Boris Vasilievich Spassky",
"nick" => "Spassky",
"citizen" => "France",
);
try { try {
$result = $collection->insertOne($hannes); $result = $collection->insertOne($hannes);
...@@ -48,7 +58,7 @@ try { ...@@ -48,7 +58,7 @@ try {
var_dump($document); var_dump($document);
} }
} catch(Exception $e) { } catch(Exception $e) {
echo $e->getMessage(), "\n"; printf("Caught exception '%s', on line %d\n", $e->getMessage(), __LINE__);
exit; exit;
} }
...@@ -69,6 +79,13 @@ try { ...@@ -69,6 +79,13 @@ try {
var_dump($person); var_dump($person);
} }
} catch(Exception $e) {
printf("Caught exception '%s', on line %d\n", $e->getMessage(), __LINE__);
exit;
}
try {
$result = $collection->updateMany( $result = $collection->updateMany(
array("citizen" => "Iceland"), array("citizen" => "Iceland"),
array('$set' => array("viking" => true)) array('$set' => array("viking" => true))
...@@ -79,6 +96,14 @@ try { ...@@ -79,6 +96,14 @@ try {
foreach($result as $document) { foreach($result as $document) {
var_dump($document); var_dump($document);
} }
} catch(Exception $e) {
printf("Caught exception '%s', on line %d\n", $e->getMessage(), __LINE__);
exit;
}
try {
echo "This is the trouble maker\n";
$result = $collection->replaceOne( $result = $collection->replaceOne(
array("nick" => "Bobby Fischer"), array("nick" => "Bobby Fischer"),
array("name" => "Magnus Carlsen", "nick" => "unknown", "citizen" => "Norway") array("name" => "Magnus Carlsen", "nick" => "unknown", "citizen" => "Norway")
...@@ -88,14 +113,20 @@ try { ...@@ -88,14 +113,20 @@ try {
foreach($result as $document) { foreach($result as $document) {
var_dump($document); var_dump($document);
} }
} catch(Exception $e) {
printf("Caught exception '%s', on line %d\n", $e->getMessage(), __LINE__);
exit;
}
try {
$result = $collection->deleteOne($document); $result = $collection->deleteOne($document);
printf("Deleted: %d (out of expected 1)\n", $result->getNumRemoved()); printf("Deleted: %d (out of expected 1)\n", $result->getNumRemoved());
$result = $collection->deleteMany(array("citizen" => "Iceland")); $result = $collection->deleteMany(array("citizen" => "Iceland"));
printf("Deleted: %d (out of expected 2)\n", $result->getNumRemoved()); printf("Deleted: %d (out of expected 2)\n", $result->getNumRemoved());
} catch(Exception $e) { } catch(Exception $e) {
echo $e->getMessage(), "\n"; printf("Caught exception '%s', on line %d\n", $e->getMessage(), __LINE__);
exit; exit;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment