You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

41 regels
737 B

  1. <?php
  2. class MMongo {
  3. /**
  4. * Throw operation exception
  5. *
  6. * @param mixed $ret the result to be checked
  7. */
  8. public static function checkException($ret) {
  9. if (!is_array($ret) || !isset($ret["ok"])) {
  10. return;
  11. }
  12. if ($ret["ok"]) {
  13. return;
  14. }
  15. if (isset($ret["assertion"])) {
  16. exit($ret["assertion"]);
  17. }
  18. if (isset($ret["errmsg"])) {
  19. exit($ret["errmsg"]);
  20. }
  21. p($ret);
  22. exit();
  23. }
  24. /**
  25. * Read exception from response result
  26. *
  27. * @param array $ret response result
  28. * @return unknown|string
  29. */
  30. public static function readException($ret) {
  31. if (!empty($ret["assertion"])) {
  32. return $ret["assertion"];
  33. }
  34. if (!empty($ret["errmsg"])) {
  35. return $ret["errmsg"];
  36. }
  37. return "unknown error";
  38. }
  39. }