MongoDB\Driver\Manager 클래스
(mongodb >=1.0.0)
소개
MongoDB\Driver\Manager는 확장에 대한 기본 진입점입니다. MongoDB(독립형 서버, 복제본 세트 또는 샤딩된 클러스터)에 대한 연결을 유지 관리하는 역할을 합니다.
Manager를 인스턴스화하면 MongoDB에 연결되지 않습니다. 이는 하나 이상의 MongoDB 서버가 다운되더라도 MongoDB\Driver\Manager를 항상 구성할 수 있음을 의미합니다.
모든 쓰기 또는 쿼리는 연결이 느리게 생성되므로 연결 예외를 throw할 수 있습니다. MongoDB 서버는 스크립트 수명 동안 사용할 수 없게 될 수도 있습니다. 따라서 관리자의 모든 작업이 try/catch 문으로 래핑되어야 합니다.
클래스 개요
final class MongoDB\Driver\Manager { /* Methods */ final public addSubscriber(MongoDB\Driver\Monitoring\Subscriber $subscriber): void final public __construct(string $uri = "mongodb://127.0.0.1/", array $uriOptions = array(), array $driverOptions = array()) final public createClientEncryption(array $options): MongoDB\Driver\ClientEncryption final public executeBulkWrite(string $namespace, MongoDB\Driver\BulkWrite $bulk, array $options = array()): MongoDB\Driver\WriteResult final public executeCommand(string $db, MongoDB\Driver\Command $command, array $options = array()): MongoDB\Driver\Cursor final public executeQuery(string $namespace, MongoDB\Driver\Query $query, array $options = array()): MongoDB\Driver\Cursor final public executeReadCommand(string $db, MongoDB\Driver\Command $command, array $options = array()): MongoDB\Driver\Cursor final public executeReadWriteCommand(string $db, MongoDB\Driver\Command $command, array $options = array()): MongoDB\Driver\Cursor final public executeWriteCommand(string $db, MongoDB\Driver\Command $command, array $options = array()): MongoDB\Driver\Cursor final public getReadConcern(): MongoDB\Driver\ReadConcern final public getReadPreference(): MongoDB\Driver\ReadPreference final public getServers(): array final public getWriteConcern(): MongoDB\Driver\WriteConcern final public removeSubscriber(MongoDB\Driver\Monitoring\Subscriber $subscriber): void final public selectServer(?MongoDB\Driver\ReadPreference $readPreference = null): MongoDB\Driver\Server final public startSession(array $options = ?): MongoDB\Driver\Session }
Examples
예제 #1 MongoDB\Driver\Manager::__construct() 기본 예제
MongoDB\Driver\Manager를 var_dump() 하면 일반적으로 노출되지 않는 관리자에 대한 다양한 세부 정보가 출력됩니다. 이것은 드라이버가 MongoDB 설정을 보는 방식과 사용되는 옵션을 디버그하는 데 유용할 수 있습니다.
<?php
$manager = new MongoDB\Driver\Manager('mongodb://localhost:27017');
var_dump($manager);
?>
위의 예는 다음과 유사한 결과를 출력합니다.
object(MongoDB\Driver\Manager)#1 (2) { ["uri"]=> string(26) "mongodb://127.0.0.1:27017/" ["cluster"]=> array(0) { } }
목차
- MongoDB\Driver\Manager::addSubscriber — 이 Manager에 모니터링 이벤트 구독자를 등록합니다.
- MongoDB\Driver\Manager::__construct — 새 MongoDB 관리자 생성
- MongoDB\Driver\Manager::createClientEncryption — 새 ClientEncryption 개체 만들기
- MongoDB\Driver\Manager::executeBulkWrite — 하나 이상의 쓰기 작업 실행
- MongoDB\Driver\Manager::executeCommand — 데이터베이스 명령 실행
- MongoDB\Driver\Manager::executeQuery — 데이터베이스 쿼리 실행
- MongoDB\Driver\Manager::executeReadCommand — 다음을 읽는 데이터베이스 명령을 실행합니다.
- MongoDB\Driver\Manager::executeReadWriteCommand — 읽고 쓰는 데이터베이스 명령 실행
- MongoDB\Driver\Manager::executeWriteCommand — 다음을 작성하는 데이터베이스 명령을 실행합니다.
- MongoDB\Driver\Manager::getReadConcern — 관리자에 대한 ReadConcern 반환
- MongoDB\Driver\Manager::getReadPreference — 관리자에 대한 ReadPreference 반환
- MongoDB\Driver\Manager::getServers — 이 관리자가 연결된 서버를 반환합니다.
- MongoDB\Driver\Manager::getWriteConcern — 관리자에 대한 WriteConcern 반환
- MongoDB\Driver\Manager::removeSubscriber — 이 Manager에서 모니터링 이벤트 가입자를 등록 취소합니다.
- MongoDB\Driver\Manager::selectServer — 읽기 기본 설정과 일치하는 서버 선택
- MongoDB\Driver\Manager::startSession — 이 클라이언트와 함께 사용할 새 클라이언트 세션 시작