1 | <?php |
||
20 | class MongoDBRef |
||
21 | { |
||
22 | /** |
||
23 | * @static |
||
24 | * @var $refKey |
||
25 | */ |
||
26 | protected static $refKey = '$ref'; |
||
27 | |||
28 | /** |
||
29 | * @static |
||
30 | * @var $idKey |
||
31 | */ |
||
32 | protected static $idKey = '$id'; |
||
33 | |||
34 | /** |
||
35 | * If no database is given, the current database is used. |
||
36 | * |
||
37 | * @link http://php.net/manual/en/mongodbref.create.php |
||
38 | * @static |
||
39 | * @param string $collection Collection name (without the database name) |
||
40 | * @param mixed $id The _id field of the object to which to link |
||
41 | * @param string $database Database name |
||
42 | * @return array Returns the reference |
||
43 | */ |
||
44 | public static function create($collection, $id, $database = null) |
||
57 | |||
58 | /** |
||
59 | * This not actually follow the reference, so it does not determine if it is broken or not. |
||
60 | * It merely checks that $ref is in valid database reference format (in that it is an object or array with $ref and $id fields). |
||
61 | * |
||
62 | * @link http://php.net/manual/en/mongodbref.isref.php |
||
63 | * @static |
||
64 | * @param mixed $ref Array or object to check |
||
65 | * @return boolean Returns true if $ref is a reference |
||
66 | */ |
||
67 | public static function isRef($ref) |
||
73 | |||
74 | /** |
||
75 | * Fetches the object pointed to by a reference |
||
76 | * @link http://php.net/manual/en/mongodbref.get.php |
||
77 | * @static |
||
78 | * @param MongoDB $db Database to use |
||
79 | * @param array $ref Reference to fetch |
||
80 | * @return array|null Returns the document to which the reference refers or null if the document does not exist (the reference is broken) |
||
81 | */ |
||
82 | public static function get($db, $ref) |
||
90 | } |
||
91 |