MongoGridFS.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 MongoGridFS extends MongoCollection {
  16. const ASCENDING = 1;
  17. const DESCENDING = -1;
  18. /**
  19. * @link http://php.net/manual/en/class.mongogridfs.php#mongogridfs.props.chunks
  20. * @var $chunks MongoCollection
  21. */
  22. public $chunks;
  23. /**
  24. * @link http://php.net/manual/en/class.mongogridfs.php#mongogridfs.props.filesname
  25. * @var $filesName string
  26. */
  27. protected $filesName;
  28. /**
  29. * @link http://php.net/manual/en/class.mongogridfs.php#mongogridfs.props.chunksname
  30. * @var $chunksName string
  31. */
  32. protected $chunksName;
  33. /**
  34. * Files as stored across two collections, the first containing file meta
  35. * information, the second containing chunks of the actual file. By default,
  36. * fs.files and fs.chunks are the collection names used.
  37. *
  38. * @link http://php.net/manual/en/mongogridfs.construct.php
  39. * @param MongoDB $db Database
  40. * @param string $prefix [optional] <p>Optional collection name prefix.</p>
  41. * @param mixed $chunks [optional]
  42. * @return MongoGridFS
  43. */
  44. public function __construct($db, $prefix = "fs", $chunks = "fs") {}
  45. /**
  46. * Drops the files and chunks collections
  47. * @link http://php.net/manual/en/mongogridfs.drop.php
  48. * @return array The database response
  49. */
  50. public function drop() {}
  51. /**
  52. * @link http://php.net/manual/en/mongogridfs.find.php
  53. * @param array $query The query
  54. * @param array $fields Fields to return
  55. * @return MongoGridFSCursor A MongoGridFSCursor
  56. */
  57. public function find(array $query = array(), array $fields = array()) {}
  58. /**
  59. * Stores a file in the database
  60. * @link http://php.net/manual/en/mongogridfs.storefile.php
  61. * @param string $filename The name of the file
  62. * @param array $extra Other metadata to add to the file saved
  63. * @param array $options Options for the store. "safe": Check that this store succeeded
  64. * @return mixed Returns the _id of the saved object
  65. */
  66. public function storeFile($filename, $extra = array(), $options = array()) {}
  67. /**
  68. * Chunkifies and stores bytes in the database
  69. * @link http://php.net/manual/en/mongogridfs.storebytes.php
  70. * @param string $bytes A string of bytes to store
  71. * @param array $extra Other metadata to add to the file saved
  72. * @param array $options Options for the store. "safe": Check that this store succeeded
  73. * @return mixed The _id of the object saved
  74. */
  75. public function storeBytes($bytes, $extra = array(), $options = array()) {}
  76. /**
  77. * Returns a single file matching the criteria
  78. * @link http://www.php.net/manual/en/mongogridfs.findone.php
  79. * @param array $query The fields for which to search.
  80. * @param array $fields Fields of the results to return.
  81. * @return MongoGridFSFile|null
  82. */
  83. public function findOne(array $query = array(), array $fields = array()) {}
  84. /**
  85. * Removes files from the collections
  86. * @link http://www.php.net/manual/en/mongogridfs.remove.php
  87. * @param array $criteria Description of records to remove.
  88. * @param array $options Options for remove. Valid options are: "safe"- Check that the remove succeeded.
  89. * @throws MongoCursorException
  90. * @return boolean
  91. */
  92. public function remove(array $criteria = array(), array $options = array()) {}
  93. /**
  94. * Delete a file from the database
  95. * @link http://php.net/manual/en/mongogridfs.delete.php
  96. * @param mixed $id _id of the file to remove
  97. * @return boolean Returns true if the remove was successfully sent to the database.
  98. */
  99. public function delete($id) {}
  100. /**
  101. * Saves an uploaded file directly from a POST to the database
  102. * @link http://www.php.net/manual/en/mongogridfs.storeupload.php
  103. * @param string $name The name attribute of the uploaded file, from <input type="file" name="something"/>.
  104. * @param array $metadata An array of extra fields for the uploaded file.
  105. * @return mixed Returns the _id of the uploaded file.
  106. */
  107. public function storeUpload($name, array $metadata = array()) {}
  108. /**
  109. * Retrieve a file from the database
  110. * @link http://www.php.net/manual/en/mongogridfs.get.php
  111. * @param mixed $id _id of the file to find.
  112. * @return MongoGridFSFile|null Returns the file, if found, or NULL.
  113. */
  114. public function __get($id) {}
  115. /**
  116. * Stores a file in the database
  117. * @link http://php.net/manual/en/mongogridfs.put.php
  118. * @param string $filename The name of the file
  119. * @param array $extra Other metadata to add to the file saved
  120. * @return mixed Returns the _id of the saved object
  121. */
  122. public function put($filename, array $extra = array()) {}
  123. }