Difference between revisions of "Core/singleton"

From PunchCMS
Jump to: navigation, search
Line 16: Line 16:
 
=== Example ===
 
=== Example ===
 
<code php>
 
<code php>
$strDSN = "mysql://user:password@localhost/database?charset=utf8";
+
$strDSN = "mysql://user:password@localhost/database?charset=utf8";<br>
$strAccount = "dfg8979r";
+
$strAccount = "dfg8979r";<br>
$strPath = dirname(__FILE__) . "/";
+
$strPath = dirname(__FILE__) . "/";<br>
  
 
$objCms = PCMS_Client::singleton($strDSN, $strAccount, $strPath);
 
$objCms = PCMS_Client::singleton($strDSN, $strAccount, $strPath);
 
</code>
 
</code>

Revision as of 00:11, 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);