API15

JDatabaseMySQL/select

From Joomla! Documentation

< API15:JDatabaseMySQL
Revision as of 17:15, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Select a database for use <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki>...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Select a database for use

[Edit Descripton]

Template:Description:JDatabaseMySQL/select

Syntax[edit]

select($database)
Parameter Name Default Value Description
$database $database

Returns[edit]

boolean True if the database has been successfully selected

Defined in[edit]

libraries/joomla/database/database/mysql.php

Importing[edit]

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

Source Body[edit]

function select($database)
{
        if ( ! $database )
        {
                return false;
        }

        if ( !mysql_select_db( $database, $this->_resource )) {
                $this->_errorNum = 3;
                $this->_errorMsg = 'Could not connect to database';
                return false;
        }

        // if running mysql 5, set sql-mode to mysql40 - thereby circumventing strict mode problems
        if ( strpos( $this->getVersion(), '5' ) === 0 ) {
                $this->setQuery( "SET sql_mode = 'MYSQL40'" );
                $this->query();
        }

        return true;
}

[Edit See Also] Template:SeeAlso:JDatabaseMySQL/select

Examples[edit]

<CodeExamplesForm />