本文整理汇总了PHP中Mongo::lastError方法的典型用法代码示例。如果您正苦于以下问题:PHP Mongo::lastError方法的具体用法?PHP Mongo::lastError怎么用?PHP Mongo::lastError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mongo
的用法示例。
在下文中一共展示了Mongo::lastError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testConstruct
public function testConstruct()
{
$m = new Mongo("localhost:27017,localhost:27018", false);
$m->pairConnect();
$c = $m->selectCollection("phpunit", "test");
$c->insert(array("foo", "bar"));
$left = new Mongo("localhost:27017");
$left->selectCollection("foo", "bar")->insert(array('x' => 1));
$lerr = $left->lastError();
$right = new Mongo("localhost:27018");
$right->selectCollection("foo", "bar")->insert(array('x' => 1));
$rerr = $right->lastError();
}
示例2: testForceError
/**
* @expectedException PHPUnit_Framework_Error
*/
public function testForceError() {
$m = new Mongo();
$m->forceError();
$err = $m->lastError();
$this->assertNotNull($err['err']);
$this->assertEquals($err['n'], 0);
$this->assertEquals((bool)$err['ok'], true);
}
示例3: fopen
$people[array_rand($people)][$factorName] = true;
}
}
return $people;
}
// Density.csv says how many people are within each tract of land
$handle = fopen('density.csv', 'r');
while (($data = fgetcsv($handle)) !== FALSE) {
$populations[substr($data[1], 13)] = (int) $data[2];
}
// This XML file contains data about the shapes of these tracts
$tracts = simplexml_load_file('2010gztract_13.kml');
$pplcnt = 0;
foreach ($tracts->Document->Placemark as $PUMA) {
// Not great XML design on their part, using regex to pull out the tract ID to match the two datasets
preg_match('/\\<td\\>(.+)\\<\\/td\\>/', $PUMA->description[0], $matches);
$population = $populations[$matches[1]];
// Space-separated list of coordinates within XML object
$polyline = explode(' ', $PUMA->Polygon[0]->outerBoundaryIs[0]->LinearRing[0]->coordinates);
// Remove the last element which is a " "
array_pop($polyline);
if (count($polyline) > 1) {
$people = insertNeighborhood($population, $polyline);
$database->weatherhack->people->batchInsert($people);
$pplcnt = $pplcnt + count($people);
echo "inserted {$pplcnt}... ";
usleep(100);
}
}
var_dump($database->lastError());