當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Mongo::__toString方法代碼示例

本文整理匯總了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();
 }
開發者ID:ud223,項目名稱:yj,代碼行數:6,代碼來源:Connection.php

示例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()));
    }
開發者ID:neurodrone,項目名稱:mongo-php-driver,代碼行數:13,代碼來源:MongoTest.php

示例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";
    }
}
開發者ID:frankff,項目名稱:mongo-snippets,代碼行數:27,代碼來源:test.php

示例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);
 }
開發者ID:redmeadowman,項目名稱:mongo-php-driver,代碼行數:11,代碼來源:RegressionTest1.php

示例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()));
 }
開發者ID:redmeadowman,項目名稱:mongo-php-driver,代碼行數:10,代碼來源:MongoTest.php


注:本文中的Mongo::__toString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。