0
replicaSet을 사용하기위한 올바른 구문을 찾고 있습니다. PHP 페이지 http://php.net/manual/en/mongo.construct.php에 대한 설명서를 볼 수 있지만 다음에 무슨 일이 일어날 지 잘 모르겠습니다.MongoDB PHP ReplicaSet 올바른 구문
<?php
// pass a comma-separated list of server names to the constructor
$m1 = new Mongo("mongodb://sf2.example.com,ny1.example.com", array("replicaSet" => "myReplSet"));
// you only need to pass a single seed, the driver will derive the full list and
// find the master from this seed
$m2 = new Mongo("mongodb://ny1.example.com", array("replicaSet" => "myReplSet"));
?>
는 다음이 나는이 내가 CodeIgniter의 내에서 사용하고 기존 클래스의 전체 내용입니다
if($m1){ $mongo = $m1; }else{ $mongo = $m2; }
같은 것을 작성해야합니다. 복제본 세트를 지원하도록 전환해야합니다.
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class CI_Mongo extends Mongo
{
var $db;
function CI_Mongo()
{
// Fetch CodeIgniter instance
$ci = get_instance();
// Load Mongo configuration file
$ci->load->config('mongo');
// Fetch Mongo server and database configuration
$server = config_item('mongo_server');
$dbname = config_item('mongo_dbname');
// Initialise Mongo
if ($server)
{
parent::__construct($server);
}
else
{
parent::__construct();
}
$this->db = $this->$dbname;
}
}
?>
와우 ... 완전히 설명서를 잘못 읽었습니다 :) 감사합니다! –
최선을 다해도 발생합니다. –