IMPRESS dotted_line CONTACT dotted_line search dotted_line Kontakt dotted_line sitemap dotted_line print
283 PHP-Resource users online

Switch to another languags Deutsch aktuelle Sprache Englisch

PHP Manual

The Mongo class

(No version information available, might only be in SVN)


A connection between PHP and MongoDB.

This class is used to create and manage connections. A typical use is:


= new Mongo(); // connect
$db $m->foo// get the database named "foo"


See Mongo::__construct() and the section on connecting for more information about creating connections.

Class synopsis

Mongo {
/* Constants */
const string VERSION ;
const string DEFAULT_HOST = "localhost" ;
const int DEFAULT_PORT = 27017 ;
/* Fields */
public boolean $connected = FALSE ;
public string $status = NULL ;
protected string $server = NULL ;
protected boolean $persistent = NULL ;
/* Methods */
public bool close ( void )
public bool connect ( void )
protected bool connectUtil ( void )
public __construct ([ string $server = "mongodb://localhost:27017" [, array $options = array("connect" => TRUE) ]] )
public array dropDB ( mixed $db )
public MongoDB __get ( string $dbname )
public array getHosts ( void )
public static int getPoolSize ( void )
public string getSlave ( void )
public bool getSlaveOkay ( void )
public array listDBs ( void )
public array poolDebug ( void )
public MongoCollection selectCollection ( string $db , string $collection )
public MongoDB selectDB ( string $name )
public static bool setPoolSize ( int $size )
public bool setSlaveOkay ([ bool $ok = true ] )
public string switchSlave ( void )
public string __toString ( void )

Predefined Constants

Mongo Constants

PHP driver version. May be suffixed with "+" or "-" if it is in-between versions.
Host to connect to if no host is given.
Port to connect to if no port is given.


If this is a persistent connection, if the connection was created for this object or is being reused. If this is not a persistent connection, this field should be NULL.

See Also

MongoDB core docs on » connecting.

Table of Contents

Comments to the PHP manual
Write new comment


New Tutorial entries

Migration einer PHP 5 App auf PHP 7

Dieses PHP 7 Tutorial zeigt dir, wie du dein PHP5 Script auf PHP7 umstellst.

Berni | Category: PHP
PHP 7 Virtual Machine

Dieser Artikel zielt darauf ab, einen Überblick über die Zend Virtual Machine, wie es in PHP 7 gefunden wird.

Berni | Category: PHP
plotting masters - a professional guide - Teil II

Grafische Interpolation und Bestapproximation von numerischen Wertepaaren: Wir wollen Punkte auf einer Zeichenebene über verschiedene Verfahren miteinander verbinden.

EVAMasters | Category: PHP