Example #1
0
 function selectAll($queryString, $fetchMode = true)
 {
     $collection = new Collection();
     $this->execute($queryString);
     while ($record = $this->fetch($fetchMode)) {
         $collection->insert($record);
     }
     return $collection;
 }
Example #2
0
 /**
  * @expectedException \Sokil\Mongo\Exception
  * @expectedExceptionMessage Insert error
  */
 public function testInsert_Unacknowledged_Error()
 {
     $this->collectionMock = $this->getMock('\\MongoCollection', array('insert'), array($this->database->getMongoDB(), 'phpmongo_test_collection'));
     $this->collectionMock->expects($this->once())->method('insert')->will($this->returnValue(false));
     $collection = new Collection($this->database, $this->collectionMock);
     $collection->setUnacknowledgedWriteConcern();
     $collection->insert(array('a' => 1, 'b' => 2));
 }
 /**
  * @param string $identifier
  * @param AssetInterface $asset
  * @param string $key
  * @return void
  */
 public function insert($identifier, AssetInterface $asset, $key)
 {
     parent::insert($identifier, $asset, $key);
     $properties = $this->getFilteredProperties($asset);
     $this->getGroupFor($properties)->insert($identifier, $asset, $key);
 }
 public function testShouldDeleteRecordsAccordingToCriteria()
 {
     $collection = new Collection(new Factory());
     $collection->insert(array('name' => 'A'));
     $collection->insert(array('name' => 'B'));
     $collection->insert(array('name' => 'C'));
     $criteria = array('name' => 'B');
     $collection->delete($criteria);
     $this->assertCount(2, $collection);
 }
Example #5
0
        Flight::ok($array);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('GET /v1/main/collection/@id', function ($id) {
    try {
        $object = Collection::select($id);
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('POST /v1/main/collection', function () {
    try {
        $object = Collection::insert();
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('PUT /v1/main/collection/@id', function ($id) {
    try {
        $object = Collection::update($id);
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('DELETE /v1/main/collection/@id', function ($id) {
    try {