Difference between revisions of "Core/singleton"
From PunchCMS
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | + | ==== PCMS_Client::singleton(dsn, punchId, basePath) ==== | |
=== Overview === | === 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 [[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]<br> |
− | + | ||
Should be a valid database ConnectionString. | Should be a valid database ConnectionString. | ||
− | '''punchId''' [string] | + | '''punchId''' [string]<br> |
− | + | ||
The account string generated by the CMS. | The account string generated by the CMS. | ||
− | '''basePath''' [string] | + | '''basePath''' [string]<br> |
− | + | ||
Absolute path to the root folder of the website. | Absolute path to the root folder of the website. | ||
=== Returns === | === Returns === | ||
The CMS object instance. | The CMS object instance. | ||
=== Example === | === Example === | ||
− | < | + | <source lang="php"> |
$strDSN = "mysql://user:password@localhost/database?charset=utf8"; | $strDSN = "mysql://user:password@localhost/database?charset=utf8"; | ||
$strAccount = "dfg8979r"; | $strAccount = "dfg8979r"; | ||
Line 24: | Line 21: | ||
$objCms = PCMS_Client::singleton($strDSN, $strAccount, $strPath); | $objCms = PCMS_Client::singleton($strDSN, $strAccount, $strPath); | ||
− | </ | + | </source> |
Latest revision as of 00:33, 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);