Difference between revisions of "Core/singleton"

From PunchCMS
Jump to: navigation, search
Line 4: Line 4:
 
Instansiate the CMS object using the database connectionstring, punch account id and website base path. This is done only once. For the rest of the code execution an instance of the CMS object can be obtained by using the [[spincms:core/getinstance|PCMS_Client::getInstance()]] call.
 
Instansiate the CMS object using the database connectionstring, punch account id and website base path. This is done only once. For the rest of the code execution an instance of the CMS object can be obtained by using the [[spincms:core/getinstance|PCMS_Client::getInstance()]] call.
 
=== Arguments ===
 
=== Arguments ===
**dsn** [string]\\
+
*dsn* [string]
 
Should be a valid database ConnectionString.
 
Should be a valid database ConnectionString.
  
**punchId** [string]\\
+
*punchId* [string]
 
The account string generated by the CMS.
 
The account string generated by the CMS.
  
**basePath** [string]\\
+
*basePath* [string]
 
Absolute path to the root folder of the website.
 
Absolute path to the root folder of the website.
 
=== Returns ===
 
=== Returns ===

Revision as of 00:04, 24 December 2008

PCMS_Client::singleton(dsn, punchId, basePath)

Overview

Instansiate the CMS object using the database connectionstring, punch account id and website base path. This is done only once. For the rest of the code execution an instance of the CMS object can be obtained by using the PCMS_Client::getInstance() call.

Arguments

  • dsn* [string]

Should be a valid database ConnectionString.

  • punchId* [string]

The account string generated by the CMS.

  • basePath* [string]

Absolute path to the root folder of the website.

Returns

The CMS object instance.

Example

$strDSN = "mysql://user:password@localhost/database?charset=utf8"; $strAccount = "dfg8979r"; $strPath = dirname(__FILE__) . "/";

$objCms = PCMS_Client::singleton($strDSN, $strAccount, $strPath);