本文整理匯總了PHP中Mongo::__toString方法的典型用法代碼示例。如果您正苦於以下問題:PHP Mongo::__toString方法的具體用法?PHP Mongo::__toString怎麽用?PHP Mongo::__toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mongo
的用法示例。
在下文中一共展示了Mongo::__toString方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __toString
/** @proxy */
public function __toString()
{
$this->initialize();
return $this->mongo->__toString();
}
示例2: test__toString2
public function test__toString2() {
$m = new Mongo("mongodb://localhost:27018,localhost:27017,localhost:27019");
$this->assertEquals("[localhost:27018],localhost:27017,[localhost:27019]", $m->__toString());
$m->foo->bar->findOne();
$this->assertEquals("[localhost:27018],localhost:27017,[localhost:27019]", $m->__toString());
$this->assertEquals(51, strlen($m->__toString()));
// realloc
$m = new Mongo("mongodb://localhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhosta:27018,localhost:27017");
$m->phpunit->c->findOne();
$this->assertEquals("[localhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhosta:27018],localhost:27017", $m->__toString());
$this->assertEquals(274, strlen($m->__toString()));
}
示例3: fopen
<?php
$handle = fopen("php://stdin", "r");
$line = fgets($handle);
$host = trim($line);
$m = new Mongo($host, array("replicaSet" => true));
// stupid freakin server list
$strSet = explode(",", $m->__toString());
$set = array();
foreach ($strSet as $server) {
$s = trim($server, "[]");
$set[$s] = true;
}
foreach ($set as $k => $v) {
echo "{$k}\n";
}
$db = $m->replset;
$x = 0;
while ($x < 5) {
try {
$z = $db->test->findOne();
$x = $z['a'];
echo "{$x}\n";
} catch (MongoException $e) {
echo "E\n";
}
}
示例4: testMongoToString
/**
* Mongo::toString() was destroying Mongo::server
*/
public function testMongoToString()
{
$m = new Mongo();
$str1 = $m->__toString();
$str2 = $m->__toString();
$this->assertEquals("localhost:27017", $str2);
$this->assertEquals($str1, $str2);
}
示例5: test__toString2
public function test__toString2()
{
$m = new Mongo("mongodb://localhost:27018,localhost:27017,localhost:27019");
$this->assertEquals("localhost:27017,[localhost:27018],[localhost:27019]", $m->__toString());
$this->assertEquals(51, strlen($m->__toString()));
// realloc
$m = new Mongo("mongodb://localhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhosta:27018,localhost:27017");
$this->assertEquals("localhost:27017,[localhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhostalocalhosta:27018]", $m->__toString());
$this->assertEquals(274, strlen($m->__toString()));
}