Examples
Mongo::close
Mongo
PHP Manual

# The Mongo class

## Introduction

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->selectDatabase(); // get a database object
?>`

## Class synopsis

Mongo
Mongo {
/* Methods */
public boolean close ( void )
public boolean connect ( void )
protected boolean connectUtil ( string `$username` , string `$password` )
__construct ([ string `$server` = `NULL` [, boolean `$connect` = `TRUE` [, boolean `$persistent` = `FALSE` [, boolean `$paired` = `FALSE` ]]]] )
public array dropDB ( mixed `$db` )
public bool forceError ( void )
public string lastError ( 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 repairDB ( MongoDB `$db` [, boolean `$preserve_cloned_files` = false [, boolean `$backup_original_files` = false ]] )
public array resetError ( void )
public MongoCollection selectCollection ( string|MongoDB `$db` , string `$collection` )
public MongoDB selectDB ( string `$dbname` )
public string __toString ( void )
}

## Table of Contents

- 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
- Mongo::forceError — Creates a database error
- Mongo::lastError — Check if there was an error on the most recent db operation performed
- Mongo::pairConnect — Connects to paired database server
- Mongo::pairPersistConnect — Creates a persistent connection with paired database servers
- Mongo::persistConnect — Creates a persistent connection with a database server
- Mongo::prevError — Checks for the last error thrown during a database operation
- Mongo::repairDB — Repairs and compacts a database
- Mongo::resetError — Clears any flagged errors on the connection
- Mongo::selectCollection — Gets a database collection
- Mongo::selectDB — Gets a database
- Mongo::__toString — String representation of this connection

Examples
Mongo::close
Mongo
PHP Manual