본문 바로가기

IT/Database

[MongoDB] php 7.X 에서 접근 방법

### PHP 7.X 에서 mongodb 연결하는 방법이 바뀌었네요.


$filter = ['uid' => $uid];

$options = [

   'projection' => ['_id' => 0],

];

$mongo  = new MongoDB\Driver\Manager('mongodb://xxx.xxx.xxx.xxx:xxxx');

$query  = new MongoDB\Driver\Query($filter, $options);

$rows   = $mongo->executeQuery('DB.COLLECTION', $query); // $mongo contains the connection object to MongoDB


foreach($rows as $r){

    $result = $r;

}


상세한건

http://php.net/manual/en/class.mongodb-driver-manager.php

여기서 확인해주세요.

'IT > Database' 카테고리의 다른 글