MongoDBRef.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /*
  3. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  4. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  5. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  6. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  7. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  8. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  10. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  13. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. */
  15. class MongoDBRef {
  16. /**
  17. * @static
  18. * @var $refKey
  19. */
  20. protected static $refKey = '$ref';
  21. /**
  22. * @static
  23. * @var $idKey
  24. */
  25. protected static $idKey = '$id';
  26. /**
  27. * If no database is given, the current database is used.
  28. *
  29. * @link http://php.net/manual/en/mongodbref.create.php
  30. * @static
  31. * @param string $collection Collection name (without the database name)
  32. * @param mixed $id The _id field of the object to which to link
  33. * @param string $database Database name
  34. * @return array Returns the reference
  35. */
  36. public static function create($collection, $id, $database = null) {}
  37. /**
  38. * This not actually follow the reference, so it does not determine if it is broken or not.
  39. * It merely checks that $ref is in valid database reference format (in that it is an object or array with $ref and $id fields).
  40. *
  41. * @link http://php.net/manual/en/mongodbref.isref.php
  42. * @static
  43. * @param mixed $ref Array or object to check
  44. * @return boolean Returns true if $ref is a reference
  45. */
  46. public static function isRef($ref) {}
  47. /**
  48. * Fetches the object pointed to by a reference
  49. * @link http://php.net/manual/en/mongodbref.get.php
  50. * @static
  51. * @param MongoDB $db Database to use
  52. * @param array $ref Reference to fetch
  53. * @return array|null Returns the document to which the reference refers or null if the document does not exist (the reference is broken)
  54. */
  55. public static function get($db, $ref) {}
  56. }