MongoClient ��

(PECL mongo >=1.3.0)

Warning

This extension that defines this class is deprecated. Instead, the MongoDB extension should be used. Alternatives to this class include:

���

PHP �� MongoDB �����ӹ�������

��������ڴ����͹������ӡ����͵��÷���

Example #1 MongoClient �����÷�

<?php

$m 
= new MongoClient(); // ����
$db $m->foo// ��ȡ����Ϊ "foo" �����ݿ�

?>

���ڴ������ӵĸ�����Ϣ���μ� MongoClient::__construct() �� connecting ���½ڡ�

��ժҪ

MongoClient {
/* ���� */
const string VERSION ;
const string DEFAULT_HOST = "localhost" ;
const int DEFAULT_PORT = 27017 ;
const string RP_PRIMARY = "primary" ;
const string RP_PRIMARY_PREFERRED = "primaryPreferred" ;
const string RP_SECONDARY = "secondary" ;
const string RP_SECONDARY_PREFERRED = "secondaryPreferred" ;
const string RP_NEAREST = "nearest" ;
/* ���� */
public boolean $connected = FALSE ;
public string $status = NULL ;
protected string $server = NULL ;
protected boolean $persistent = NULL ;
/* ���� */
public __construct ([ string $server = "mongodb://localhost:27017" [, array $options = array("connect" => TRUE) ]] )
public close ([ boolean|string $connection ] ) : bool
public connect ( void ) : bool
public dropDB ( mixed $db ) : array
public __get ( string $dbname ) : MongoDB
public static getConnections ( void ) : array
public getHosts ( void ) : array
public getReadPreference ( void ) : array
public getWriteConcern ( void ) : array
public killCursor ( string $server_hash , int|MongoInt64 $id ) : bool
public listDBs ( void ) : array
public selectCollection ( string $db , string $collection ) : MongoCollection
public selectDB ( string $name ) : MongoDB
public setReadPreference ( string $read_preference [, array $tags ] ) : bool
public setWriteConcern ( mixed $w [, int $wtimeout ] ) : bool
public __toString ( void ) : string
}

Ԥ���峣��

MongoClient ����

MongoClient::VERSION
PHP �����汾���п��ܸ��� "dev"��"+" �� "-" ������������汾֮�䡣
MongoClient::DEFAULT_HOST
"localhost"
���û��ָ��������Ĭ�����Ӹ�������
MongoClient::DEFAULT_PORT
27017
���û��ָ���˿ڣ�Ĭ�����Ӹö˿ڡ�
MongoClient::RP_PRIMARY
"primary"
��������Ծ�ڵ����ȡѡ����
MongoClient::RP_PRIMARY_PREFERRED
"primaryPreferred"
��������Ծ�ڵ����ȡѡ����
MongoClient::RP_SECONDARY
"secondary"
���������ݽڵ����ȡѡ����
MongoClient::RP_SECONDARY_PREFERRED
"secondaryPreferred"
���������ݽڵ����ȡѡ����
MongoClient::RP_NEAREST
"nearest"
����������ڵ����ȡѡ����

�ֶ�����

connected

���������һ���򿪵����ݿ����ӣ����ᱻ����Ϊ TRUE�������� FALSE�� ������Ӹ�������replica set����һ���ڵ㲢ƥ�䵱ǰ�Ķ�ȡѡ�� �������Խ����� TRUE�� ������Բ������˻��Ƿ�����֤��

�汾 1.5.0 ��������Ѿ������� deprecated����

status

������Բ����ٱ�ʹ�ã����ᱻ����Ϊ NULL �������汾 1.1.x ������汾�У�ʹ�ó־�����ʱ����ܻᱻ����Ϊ�ַ�����ֵ(���� "recycled"�� "new")��

�汾 1.5.0 ��������Ѿ������� deprecated����

�μ�

Table of Contents