本文整理汇总了PHP中Collection::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::insert方法的具体用法?PHP Collection::insert怎么用?PHP Collection::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collection
的用法示例。
在下文中一共展示了Collection::insert方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: selectAll
function selectAll($queryString, $fetchMode = true)
{
$collection = new Collection();
$this->execute($queryString);
while ($record = $this->fetch($fetchMode)) {
$collection->insert($record);
}
return $collection;
}
示例2: testInsert_Unacknowledged_Error
/**
* @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));
}
示例3: insert
/**
* @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);
}
示例4: testShouldDeleteRecordsAccordingToCriteria
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);
}
示例5: catch
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 {