Difference between revisions of "Core/setDbConnection"

From PunchCMS
Jump to: navigation, search
(New page: __NOTOC__ ==== PCMS_Client->setDbConnection([reInit]) ==== === Overview === Reset the internal database connection. Because of the singleton setup of the database connection it needs to be...)
 
(Arguments)
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:
 
Reset the internal database connection. Because of the singleton setup of the database connection it needs to be reset after working with a different database than the CMS database. This could be considered a MDB2 bug.
 
Reset the internal database connection. Because of the singleton setup of the database connection it needs to be reset after working with a different database than the CMS database. This could be considered a MDB2 bug.
 
=== Arguments ===
 
=== Arguments ===
'''reInit''' [boolean] <br>
+
'''reInit''' [boolean, ''optional''] <br>
 
'''TRUE''' re-initialize the connection, '''FALSE''' will only reset it using the singleton method. Default is '''FALSE'''.
 
'''TRUE''' re-initialize the connection, '''FALSE''' will only reset it using the singleton method. Default is '''FALSE'''.
 +
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.

Latest revision as of 22:45, 25 December 2008

PCMS_Client->setDbConnection([reInit])

Overview

Reset the internal database connection. Because of the singleton setup of the database connection it needs to be reset after working with a different database than the CMS database. This could be considered a MDB2 bug.

Arguments

reInit [boolean, optional]
TRUE re-initialize the connection, FALSE will only reset it using the singleton method. Default is FALSE.

Returns

Nothing.

Example

$objCms = PCMS_Client::getInstance();
 
// Write a log entry to a client specific database.
$intPageId = $objCms->getAliasId();
$objLog = DB_DataObject::factory('weblog');
$objLog->page = $intPageId;
$objLog->date = date();
$objLog->insert();
 
// Now we have to re-initialize the connection for the CMS object.
$objCms->setDbConnection(TRUE);