Actions

API16

Difference between revisions of "JDatabaseMySQL/ construct"

From Joomla! Documentation

< API16:JDatabaseMySQL
(New page: ===Description=== Database object constructor <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</...)
 
m (removing red link to edit, no existant pages)
 
Line 3: Line 3:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JDatabaseMySQL/__construct|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JDatabaseMySQL/__construct}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 63: Line 63:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JDatabaseMySQL/__construct|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JDatabaseMySQL/__construct}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
Line 78: Line 78:
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API16]]

Latest revision as of 20:59, 12 May 2013

Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Database object constructor

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

__construct($options)
Parameter Name Default Value Description
$options List of options used to configure the connection

Defined in

libraries/joomla/database/database/mysql.php

Importing

jimport( 'joomla.database.database.mysql' );

Source Body

function __construct($options)
{
        $host           = array_key_exists('host', $options)    ? $options['host']              : 'localhost';
        $user           = array_key_exists('user', $options)    ? $options['user']              : '';
        $password       = array_key_exists('password',$options) ? $options['password']  : '';
        $database       = array_key_exists('database',$options) ? $options['database']  : '';
        $prefix         = array_key_exists('prefix', $options)  ? $options['prefix']    : 'jos_';
        $select         = array_key_exists('select', $options)  ? $options['select']    : true;
 
        // Perform a number of fatality checks, then return gracefully
        if (!function_exists('mysql_connect')) {
                $this->_errorNum = 1;
                $this->_errorMsg = 'The MySQL adapter "mysql" is not available.';
                return;
        }
 
        // Connect to the server
        if (!($this->_connection = @mysql_connect($host, $user, $password, true))) {
                $this->_errorNum = 2;
                $this->_errorMsg = 'Could not connect to MySQL';
                return;
        }
 
        // Finalize initialisation
        parent::__construct($options);
 
        // select the database
        if ($select) {
                $this->select($database);
        }
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />