PageRenderTime 52ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

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

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