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...)
(No difference)

Revision as of 22:44, 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]
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);