PageRenderTime 51ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/phalcon/devtools/ide/0.8.0/Phalcon/Mvc/Collection.php

https://gitlab.com/habracoder/advertising
PHP | 486 lines | 52 code | 85 blank | 349 comment | 0 complexity | ef14773ed70757eeb079fd7f214e03c1 MD5 | raw file
  1. <?php
  2. namespace Phalcon\Mvc {
  3. /**
  4. * Phalcon\Mvc\Collection
  5. *
  6. * This component implements a high level abstraction for NoSQL databases which
  7. * works with documents
  8. */
  9. class Collection {
  10. const OP_NONE = 0;
  11. const OP_CREATE = 1;
  12. const OP_UPDATE = 2;
  13. const OP_DELETE = 3;
  14. protected $_dependencyInjector;
  15. protected $_modelsManager;
  16. protected $_source;
  17. protected $_operationMade;
  18. protected $_connection;
  19. protected $_errorMessages;
  20. protected static $_reserved;
  21. protected static $_disableEvents;
  22. /**
  23. * \Phalcon\Mvc\Model constructor
  24. *
  25. * @param \Phalcon\DiInterface $dependencyInjector
  26. * @param \Phalcon\Mvc\Collection\ManagerInterface $modelsManager
  27. */
  28. final public function __construct($dependencyInjector=null, $modelsManager=null){ }
  29. /**
  30. * Sets a value for the _id propery, creates a MongoId object if needed
  31. *
  32. * @param mixed $id
  33. */
  34. public function setId($id){ }
  35. /**
  36. * Returns the value of the _id property
  37. *
  38. * @return MongoId
  39. */
  40. public function getId(){ }
  41. /**
  42. * Sets the dependency injection container
  43. *
  44. * @param \Phalcon\DiInterface $dependencyInjector
  45. */
  46. public function setDI($dependencyInjector){ }
  47. /**
  48. * Returns the dependency injection container
  49. *
  50. * @return \Phalcon\DiInterface
  51. */
  52. public function getDI(){ }
  53. /**
  54. * Sets a custom events manager
  55. *
  56. * @param \Phalcon\Events\ManagerInterface $eventsManager
  57. */
  58. protected function setEventsManager(){ }
  59. /**
  60. * Returns the custom events manager
  61. *
  62. * @return \Phalcon\Events\ManagerInterface
  63. */
  64. protected function getEventsManager(){ }
  65. /**
  66. * Returns an array with reserved properties that cannot be part of the insert/update
  67. *
  68. * @return array
  69. */
  70. public function getReservedAttributes(){ }
  71. /**
  72. * Sets collection name which model should be mapped
  73. *
  74. * @param string $source
  75. * @return \Phalcon\Mvc\Collection
  76. */
  77. protected function setSource(){ }
  78. /**
  79. * Returns collection name mapped in the model
  80. *
  81. * @return string
  82. */
  83. public function getSource(){ }
  84. /**
  85. * Sets the DependencyInjection connection service name
  86. *
  87. * @param string $connectionService
  88. * @return \Phalcon\Mvc\Model
  89. */
  90. public function setConnectionService($connectionService){ }
  91. /**
  92. * Returns DependencyInjection connection service
  93. *
  94. * @return string
  95. */
  96. public function getConnectionService(){ }
  97. /**
  98. * Retrieves a database connection
  99. *
  100. * @return MongoDb
  101. */
  102. public function getConnection(){ }
  103. /**
  104. * Reads an attribute value by its name
  105. *
  106. * <code>
  107. * echo $robot->readAttribute('name');
  108. * </code>
  109. *
  110. * @param string $attribute
  111. * @return mixed
  112. */
  113. public function readAttribute($attribute){ }
  114. /**
  115. * Writes an attribute value by its name
  116. *
  117. * <code>
  118. * $robot->writeAttribute('name', 'Rosey');
  119. * </code>
  120. *
  121. * @param string $attribute
  122. * @param mixed $value
  123. */
  124. public function writeAttribute($attribute, $value){ }
  125. /**
  126. * Returns a cloned collection
  127. *
  128. * @param \Phalcon\Mvc\Collection $collection
  129. * @param array $document
  130. * @return \Phalcon\Mvc\Collection
  131. */
  132. public static function dumpResult($collection, $document){ }
  133. /**
  134. * Returns a collection resultset
  135. *
  136. * @param array $params
  137. * @param \Phalcon\Mvc\Collection $collection
  138. * @param MongoDb $connection
  139. * @param boolean $unique
  140. * @return array
  141. */
  142. protected static function _getResultset(){ }
  143. /**
  144. * Executes internal hooks before save a document
  145. *
  146. * @param \Phalcon\DI $dependencyInjector
  147. * @param boolean $disableEvents
  148. * @param boolean $exists
  149. * @return boolean
  150. */
  151. protected function _preSave(){ }
  152. /**
  153. * Executes internal events after save a document
  154. *
  155. * @param boolean $disableEvents
  156. * @param boolean $success
  157. * @param boolean $exists
  158. * @return boolean
  159. */
  160. protected function _postSave(){ }
  161. /**
  162. * Executes validators on every validation call
  163. *
  164. *<code>
  165. *use \Phalcon\Mvc\Model\Validator\ExclusionIn as ExclusionIn;
  166. *
  167. *class Subscriptors extends \Phalcon\Mvc\Collection
  168. *{
  169. *
  170. * public function validation()
  171. * {
  172. * $this->validate(new ExclusionIn(array(
  173. * 'field' => 'status',
  174. * 'domain' => array('A', 'I')
  175. * )));
  176. * if ($this->validationHasFailed() == true) {
  177. * return false;
  178. * }
  179. * }
  180. *
  181. *}
  182. *</code>
  183. *
  184. * @param object $validator
  185. */
  186. protected function validate(){ }
  187. /**
  188. * Check whether validation process has generated any messages
  189. *
  190. *<code>
  191. *use \Phalcon\Mvc\Model\Validator\ExclusionIn as ExclusionIn;
  192. *
  193. *class Subscriptors extends \Phalcon\Mvc\Model
  194. *{
  195. *
  196. * public function validation()
  197. * {
  198. * $this->validate(new ExclusionIn(array(
  199. * 'field' => 'status',
  200. * 'domain' => array('A', 'I')
  201. * )));
  202. * if ($this->validationHasFailed() == true) {
  203. * return false;
  204. * }
  205. * }
  206. *
  207. *}
  208. *</code>
  209. *
  210. * @return boolean
  211. */
  212. public function validationHasFailed(){ }
  213. /**
  214. * Fires an internal event
  215. *
  216. * @param string $eventName
  217. * @return boolean
  218. */
  219. public function fireEvent($eventName){ }
  220. /**
  221. * Fires an internal event that cancels the operation
  222. *
  223. * @param string $eventName
  224. * @return boolean
  225. */
  226. public function fireEventCancel($eventName){ }
  227. /**
  228. * Cancel the current operation
  229. *
  230. * @return boolean
  231. */
  232. protected function _cancelOperation(){ }
  233. /**
  234. * Checks if the document exists in the collection
  235. *
  236. * @param MongoCollection $collection
  237. */
  238. protected function _exists(){ }
  239. /**
  240. * Returns all the validation messages
  241. *
  242. * <code>
  243. *$robot = new Robots();
  244. *$robot->type = 'mechanical';
  245. *$robot->name = 'Astro Boy';
  246. *$robot->year = 1952;
  247. *if ($robot->save() == false) {
  248. * echo "Umh, We can't store robots right now ";
  249. * foreach ($robot->getMessages() as $message) {
  250. * echo $message;
  251. * }
  252. *} else {
  253. * echo "Great, a new robot was saved successfully!";
  254. *}
  255. * </code>
  256. *
  257. * @return \Phalcon\Mvc\Model\MessageInterface[]
  258. */
  259. public function getMessages(){ }
  260. /**
  261. * Appends a customized message on the validation process
  262. *
  263. *<code>
  264. * use \Phalcon\Mvc\Model\Message as Message;
  265. *
  266. * class Robots extends \Phalcon\Mvc\Model
  267. * {
  268. *
  269. * public function beforeSave()
  270. * {
  271. * if (this->name == 'Peter') {
  272. * $message = new Message("Sorry, but a robot cannot be named Peter");
  273. * $this->appendMessage($message);
  274. * }
  275. * }
  276. * }
  277. *</code>
  278. *
  279. * @param \Phalcon\Mvc\Model\MessageInterface $message
  280. */
  281. public function appendMessage($message){ }
  282. /**
  283. * Creates/Updates a collection based on the values in the atributes
  284. *
  285. * @return boolean
  286. */
  287. public function save(){ }
  288. /**
  289. * Find a document by its id
  290. *
  291. * @param string $id
  292. * @return \Phalcon\Mvc\Collection
  293. */
  294. public static function findById($id){ }
  295. /**
  296. * Allows to query the first record that match the specified conditions
  297. *
  298. * <code>
  299. *
  300. * //What's the first robot in robots table?
  301. * $robot = Robots::findFirst();
  302. * echo "The robot name is ", $robot->name;
  303. *
  304. * //What's the first mechanical robot in robots table?
  305. * $robot = Robots::findFirst(array(
  306. * array("type" => "mechanical")
  307. * ));
  308. * echo "The first mechanical robot name is ", $robot->name;
  309. *
  310. * //Get first virtual robot ordered by name
  311. * $robot = Robots::findFirst(array(
  312. * array("type" => "mechanical"),
  313. * "order" => array("name" => 1)
  314. * ));
  315. * echo "The first virtual robot name is ", $robot->name;
  316. *
  317. * </code>
  318. *
  319. * @param array $parameters
  320. * @return array
  321. */
  322. public static function findFirst($parameters=null){ }
  323. /**
  324. * Allows to query a set of records that match the specified conditions
  325. *
  326. * <code>
  327. *
  328. * //How many robots are there?
  329. * $robots = Robots::find();
  330. * echo "There are ", count($robots);
  331. *
  332. * //How many mechanical robots are there?
  333. * $robots = Robots::find(array(
  334. * array("type" => "mechanical")
  335. * ));
  336. * echo "There are ", count($robots);
  337. *
  338. * //Get and print virtual robots ordered by name
  339. * $robots = Robots::findFirst(array(
  340. * array("type" => "virtual"),
  341. * "order" => array("name" => 1)
  342. * ));
  343. * foreach ($robots as $robot) {
  344. * echo $robot->name, "\n";
  345. * }
  346. *
  347. * //Get first 100 virtual robots ordered by name
  348. * $robots = Robots::find(array(
  349. * array("type" => "virtual"),
  350. * "order" => array("name" => 1),
  351. * "limit" => 100
  352. * ));
  353. * foreach ($robots as $robot) {
  354. * echo $robot->name, "\n";
  355. * }
  356. * </code>
  357. *
  358. * @param array $parameters
  359. * @return array
  360. */
  361. public static function find($parameters=null){ }
  362. /**
  363. * Perform a count over a collection
  364. *
  365. *<code>
  366. * echo 'There are ', Robots::count(), ' robots';
  367. *</code>
  368. *
  369. * @param array $parameters
  370. * @return array
  371. */
  372. public static function count($parameters=null){ }
  373. /**
  374. * Deletes a model instance. Returning true on success or false otherwise.
  375. *
  376. * <code>
  377. *$robot = Robots::findFirst();
  378. *$robot->delete();
  379. *
  380. *foreach(Robots::find() as $robot){
  381. * $robot->delete();
  382. *}
  383. * </code>
  384. *
  385. * @return boolean
  386. */
  387. public function delete(){ }
  388. /**
  389. * Serializes the object ignoring connections or protected properties
  390. *
  391. * @return string
  392. */
  393. public function serialize(){ }
  394. /**
  395. * Unserializes the object from a serialized string
  396. *
  397. * @param string $data
  398. */
  399. public function unserialize($data){ }
  400. }
  401. }