Core Classes
Mongo::close
Core Classes
PHP Manual

# The Mongo class

## Introdução

The connection point between MongoDB and PHP.

This class is used to initiate a connection and for database server commands. A typical use is:

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

See Mongo::__construct() for more information about creating connections.

## Sinopse da classe

Mongo
Mongo {
/* Constants */
const string Mongo::VERSION ;
const string Mongo::DEFAULT_HOST = "localhost" ;
const int Mongo::DEFAULT_PORT = 27017 ;
/* Fields */
public boolean $connected = `FALSE` ;
protected string $server = localhost:27017 ;
protected boolean $persistent = `FALSE` ;
/* Methods */
public boolean close ( void )
public boolean connect ( void )
protected boolean connectUtil ( void )
__construct ([ string `$server` = "mongodb://localhost:27017" [, array `$options` = array("connect" => `TRUE`) ]] )
public array dropDB ( mixed `$db` )
public bool forceError ( void )
public MongoDB __get ( string `$dbname` )
public array lastError ( void )
public array listDBs ( void )
public boolean pairConnect ( void )
public boolean pairPersistConnect ([ string `$username` = "" [, string `$password` = "" ]] )
public boolean persistConnect ([ string `$username` = "" [, string `$password` = "" ]] )
public array prevError ( void )
public array resetError ( void )
public MongoCollection selectCollection ( string `$db` , string `$collection` )
public MongoDB selectDB ( string `$name` )
public string __toString ( void )
}

## Constantes pré-definidas

## Mongo Constants

`Mongo::VERSION`
  PHP driver version. May be suffixed with "+" or "-" if it is in-between versions.
`Mongo::DEFAULT_HOST`
`"localhost"`
  Host to connect to if no host is given.
`Mongo::DEFAULT_PORT`
`27017`
  Port to connect to if no port is given.

## Veja Também

MongoDB core docs on » connecting.

## Índice

- Mongo::close — Closes this database connection
- Mongo::connect — Connects to a database server
- Mongo::connectUtil — Connects with a database server
- Mongo::__construct — Creates a new database connection object
- Mongo::dropDB — Drops a database [deprecated]
- Mongo::forceError — Creates a database error on the database [deprecated]
- Mongo::__get — Gets a database
- Mongo::lastError — Check if there was an error on the most recent db operation performed [deprecated]
- Mongo::listDBs — Lists all of the databases available.
- Mongo::pairConnect — Connects to paired database server [deprecated]
- Mongo::pairPersistConnect — Creates a persistent connection with paired database servers [deprecated]
- Mongo::persistConnect — Creates a persistent connection with a database server [deprecated]
- Mongo::prevError — Checks for the last error thrown during a database operation [deprecated]
- Mongo::resetError — Clears any flagged errors on the connection [deprecated]
- Mongo::selectCollection — Gets a database collection
- Mongo::selectDB — Gets a database
- Mongo::__toString — String representation of this connection

Core Classes
Mongo::close
Core Classes
PHP Manual