本文整理汇总了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()));
}