Table of Contents

__construct

API Package Subpackage Class Method Reference Last reviewed Doc status
API Home Package Joomla.Framework Subpackage Database Class JDatabase Method __construct Reference __construct() Never Work in Progress

The constructor for the database class. The construct is responsible for opening a connection to the database and setting any necessary settings.

Syntax

JDatabase __construct ( $host, $user, $pass, $db, $table_prefix )

$host string is the URL of the system that is hosting the database. Usually ‘localhost’. This parameter is optional and if omitted will default to ‘localhost’.
$user string is the username required to connect to the database.
$pass string is the password associated with $user to be used to connect to the database.
$db string is the name of the database.
$table_prefix string is the string that will be prefixed to all table names. From Joomla! 1.5 this parameter is optional and if omitted will default to ‘jos_’.

Examples

Example

$host = 'localhost';
$user = 'joomlauser';
$password = 'itsasecret';
$dbase = 'test';
$dbprefix = 'jos_';
$db = new JDatabase( $host, $user, $password, $dbase, $dbprefix );