Mvc\Collection::findById

public static findById (mixed $id) Find a document by its id (_id) // Find user by using \MongoId object $user = Users::findById(new \MongoId('545eb081631d16153a293a66')); // Find user by using id as sting $user = Users::findById('45cbc4a0e4123f6920000002'); // Validate input if ($user = Users::findById($_POST['id'])) { // ... }

Mvc\Collection::createIfNotExist

public createIfNotExist (array $criteria) Creates a document based on the values in the attributes, if not found by criteria Preferred way to avoid duplication is to create index on attribute $robot = new Robot(); $robot->name = “MyRobot”; $robot->type = “Droid”; //create only if robot with same name and type does not exist $robot->createIfNotExist( array( “name”, “type” ) );

Mvc\Collection::fireEvent

public fireEvent (mixed $eventName) Fires an internal event

Mvc\Collection::delete

public delete () Deletes a model instance. Returning true on success or false otherwise. $robot = Robots::findFirst(); $robot->delete(); foreach (Robots::find() as $robot) { $robot->delete(); }

Mvc\Collection::appendMessage

public appendMessage (Phalcon\Mvc\Model\MessageInterface $message) Appends a customized message on the validation process use \Phalcon\Mvc\Model\Message as Message; class Robots extends \Phalcon\Mvc\Model { public function beforeSave() { if ($this->name == 'Peter') { message = new Message("Sorry, but a robot cannot be named Peter"); $this->appendMessage(message); } } }

Mvc\Collection::aggregate

public static aggregate ([array $parameters]) Perform an aggregation using the Mongo aggregation framework

Mvc\Collection

implements Phalcon\Mvc\EntityInterface, Phalcon\Mvc\CollectionInterface, Phalcon\Di\InjectionAwareInterface, Serializable Source on GitHub This component implements a high level abstraction for NoSQL databases which works with documents Constants integer OP_NONE integer OP_CREATE integer OP_UPDATE integer OP_DELETE Methods final public __construct ([Phalcon\DiInterface $dependencyInjector], [Phalcon\Mvc\Collection\ManagerInterface $modelsManager]) Phalcon\Mvc\Collection constructor publ

Mvc\Collection::count

public static count ([array $parameters]) Perform a count over a collection echo 'There are ', Robots::count(), ' robots';

Mvc\Collection::cloneResult

public static cloneResult (Phalcon\Mvc\CollectionInterface $collection, array $document) Returns a cloned collection

Mvc\Application

extends abstract class Phalcon\Application implements Phalcon\Di\InjectionAwareInterface, Phalcon\Events\EventsAwareInterface Source on GitHub This component encapsulates all the complex operations behind instantiating every component needed and integrating it with the rest to allow the MVC pattern to operate as desired. use Phalcon\Mvc\Application; class MyApp extends Application { /** * Register the services here to make them general or register * in the ModuleDefinition to