라이브러리
[PHP] MongoDBDriverCursorInterface::getServer - 이 커서와 연관된 서버를 반환합니다.
MongoDBDriverCursorInterface::getServer
`MongoDBDriverCursorInterface::getServer` 메소드는 MongoDB 드라이버의 커서 인터페이스에 속하는 메소드입니다. 이 메소드는 커서가 연결된 서버의 정보를 반환합니다.
사용 방법
`getServer` 메소드는 다음 형식으로 사용할 수 있습니다.
#hostingforum.kr
php
$server = $cursor->getServer();
예제
아래 예제는 MongoDB 드라이버의 커서 인터페이스를 사용하여 데이터베이스에 연결하고, 커서를 생성한 후 `getServer` 메소드를 사용하여 커서가 연결된 서버의 정보를 반환하는 코드입니다.
#hostingforum.kr
php
// MongoDB 드라이버를 로드합니다.
use MongoDBClient;
// MongoDB 클라이언트를 생성합니다.
$client = new Client('mongodb://localhost:27017');
// 데이터베이스에 연결합니다.
$db = $client->test;
// 컬렉션에 데이터를 삽입합니다.
$db->test->insertOne(['name' => 'John Doe']);
// 컬렉션에서 데이터를 조회합니다.
$cursor = $db->test->find();
// 커서가 연결된 서버의 정보를 반환합니다.
$server = $cursor->getServer();
// 서버의 정보를 출력합니다.
print_r($server);
출력
아래는 예제 코드를 실행한 후 출력된 결과입니다.
#hostingforum.kr
php
MongoDBServerInfo Object
(
[host] => localhost:27017
[type] => unknown
[roundTripTime] => 0.0007
[ok] => 1
[minWireVersion] => 0
[maxWireVersion] => 13
[maxBsonObjectSize] => 16777216
[maxMessageSizeBytes] => 16777216
[maxScan] => 16777216
[maxWaitQueueMultiple] => 10
[maxWaitQueueTimeMS] => 10000
[heartbeatFrequencyMS] => 10000
[minorErrorModes] => 0
[serverCapabilities] => 13
[serverCapabilitiesExt] => Array
(
)
[namespaceLength] => 128
[pipelineMaxMemory] => 104857600
[pipelineMaxBSONSize] => 16777216
[pipelineMaxDocumentSize] => 16777216
[pipelineMaxArraySize] => 16777216
[pipelineMaxBSONElementSize] => 16777216
[pipelineMaxBSON] => 16777216
[pipelineMaxMessageSizeBytes] => 16777216
[pipelineMaxScan] => 16777216
[pipelineMaxWaitQueueMultiple] => 10
[pipelineMaxWaitQueueTimeMS] => 10000
[pipelineHeartbeatFrequencyMS] => 10000
[pipelineMinorErrorModes] => 0
[pipelineServerCapabilities] => 13
[pipelineServerCapabilitiesExt] => Array
(
)
[maxBsonObjectSize] => 16777216
[maxMessageSizeBytes] => 16777216
[maxScan] => 16777216
[maxWaitQueueMultiple] => 10
[maxWaitQueueTimeMS] => 10000
[heartbeatFrequencyMS] => 10000
[minorErrorModes] => 0
[serverCapabilities] => 13
[serverCapabilitiesExt] => Array
(
)
[namespaceLength] => 128
[pipelineMaxMemory] => 104857600
[pipelineMaxBSONSize] => 16777216
[pipelineMaxDocumentSize] => 16777216
[pipelineMaxArraySize] => 16777216
[pipelineMaxBSONElementSize] => 16777216
[pipelineMaxBSON] => 16777216
[pipelineMaxMessageSizeBytes] => 16777216
[pipelineMaxScan] => 16777216
[pipelineMaxWaitQueueMultiple] => 10
[pipelineMaxWaitQueueTimeMS] => 10000
[pipelineHeartbeatFrequencyMS] => 10000
[pipelineMinorErrorModes] => 0
[pipelineServerCapabilities] => 13
[pipelineServerCapabilitiesExt] => Array
(
)
)
위의 예제 코드를 실행한 후 출력된 결과는 MongoDB 서버의 정보를 나타냅니다. 이 정보를 사용하여 MongoDB 서버의 상태를 확인하거나, 서버의 설정을 변경할 수 있습니다.
-
- 나우호스팅 @pcs8404
-
호스팅포럼 화이팅!
댓글목록
등록된 댓글이 없습니다.