PHP Doku:: The Mongo class - class.mongo.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzDatenbankerweiterungenAnbieterspezifische DatenbankerweiterungenMongoDB Native DriverCore ClassesThe Mongo class

Ein Service von Reinhard Neidl - Webprogrammierung.

Core Classes

<<Core Classes

Mongo::close>>


UnterSeiten:

The Mongo class

Einführung

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.

Klassenbeschreibung

Mongo {
/* Konstanten */
const string Mongo::VERSION ;
const string Mongo::DEFAULT_HOST = "localhost" ;
const int Mongo::DEFAULT_PORT = 27017 ;
/* Fields */
public boolean $connected = FALSE ;
public string $status = NULL ;
protected string $server = NULL ;
protected boolean $persistent = NULL ;
/* Methoden */
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 MongoDB __get ( string $dbname )
public array getHosts ( void )
public string getSlave ( void )
public boolean getSlaveOkay ( void )
public array listDBs ( void )
public MongoCollection selectCollection ( string $db , string $collection )
public MongoDB selectDB ( string $name )
public boolean setSlaveOkay ( boolean $ok )
public string switchSlave ( void )
public string __toString ( void )
}

Vordefinierte Konstanten

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.

Fields

status
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.

Siehe auch

MongoDB core docs on » connecting.

Inhaltsverzeichnis


Ein BenutzerBeitrag:
- Beiträge aktualisieren...
markh789 at gmail dot com
8.01.2011 2:32
Here is a simple connection function :)

<?php
function MongoConnect($username, $password, $database, $host) {
   
$con = new Mongo("mongodb://{$username}:{$password}@{$host}"); // Connect to Mongo Server
   
$db = $con->selectDB($database); // Connect to Database
}
?>



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)