public function testFullFluency() { $expected = array('bob' => 'hoskins', 'abc' => 12); $query = new Morph_Query(); $query->limit(10)->skip(12)->property('bob')->equals('hoskins')->property('abc')->equals(12); $this->assertEquals($expected, $query->getRawQuery()); $this->assertEquals(10, $query->getLimit()); $this->assertEquals(12, $query->getSkip()); }
<?php //Create and instance of Morph_Storage passing in the appropriate database $mongo = new Mongo(); $storage = new Morph_Storage($mongo->selectDb('myDB')); //Find a maximum of 10 users that has more than 15 posts, skipping the first 10 $query = new Morph_Query(); $query->limit(10)->skip(10)->property('numberOfPosts')->greaterThan(15); $users = $storage->findByQuery(new User(), $query);
/** * Sets the limit for the result set * * @param int $limit * @return Morph_Query */ public function limit($limit) { return $this->query->limit($limit); }
<?php //Initialise Morph_Storage passing in the appropriate database $mongo = new Mongo(); Morph_Storage::init($mongo->selectDb('myDB')); //Find a maximum of 10 users that has more than 15 posts, skipping the first 10 $user = new User(); $query = new Morph_Query(); $query->limit(10) ->skip(10) ->property('numberOfPosts') ->greaterThan(15); $users = $user->findByQuery($query);