本文整理汇总了PHP中xPDO::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP xPDO::getInstance方法的具体用法?PHP xPDO::getInstance怎么用?PHP xPDO::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xPDO
的用法示例。
在下文中一共展示了xPDO::getInstance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
/**
* Grab a persistent instance of the xPDO class to share sample model data
* across multiple tests and test suites.
*
* @param boolean $new Indicate if a new singleton should be created
* @return xPDO An xPDO object instance.
*/
public static function &getInstance($new = false)
{
if ($new || !is_object(xPDOTestHarness::$xpdo)) {
$driver = xPDOTestHarness::$properties['xpdo_driver'];
$xpdo = xPDO::getInstance(null, xPDOTestHarness::$properties["{$driver}_array_options"]);
if (is_object($xpdo)) {
$logLevel = array_key_exists('logLevel', xPDOTestHarness::$properties) ? xPDOTestHarness::$properties['logLevel'] : xPDO::LOG_LEVEL_WARN;
$logTarget = array_key_exists('logTarget', xPDOTestHarness::$properties) ? xPDOTestHarness::$properties['logTarget'] : (XPDO_CLI_MODE ? 'ECHO' : 'HTML');
$xpdo->setLogLevel($logLevel);
$xpdo->setLogTarget($logTarget);
if (!empty(xPDOTestHarness::$debug)) {
$xpdo->setDebug(xPDOTestHarness::$properties['debug']);
}
$xpdo->setPackage('sample', xPDOTestHarness::$properties['xpdo_test_path'] . 'model/');
xPDOTestHarness::$xpdo = $xpdo;
}
}
return xPDOTestHarness::$xpdo;
}
示例2: set_time_limit
/**
* Slackify package builder
*
* @author Ivan Klimchuk <ivan@klimchuk.com>
* @package slackNotify
* @subpackage build
*/
set_time_limit(0);
ini_set('date.timezone', 'Europe/Minsk');
define('PKG_NAME', 'Slackify');
define('PKG_NAME_LOWER', strtolower(PKG_NAME));
define('PKG_VERSION', '0.8.1');
define('PKG_RELEASE', 'pl');
require_once 'xpdo/xpdo/xpdo.class.php';
require_once 'xpdo/xpdo/transport/xpdotransport.class.php';
$xpdo = xPDO::getInstance('db', [xPDO::OPT_CACHE_PATH => __DIR__ . '/../cache/', xPDO::OPT_HYDRATE_FIELDS => true, xPDO::OPT_HYDRATE_RELATED_OBJECTS => true, xPDO::OPT_HYDRATE_ADHOC_FIELDS => true, xPDO::OPT_CONNECTIONS => [['dsn' => 'mysql:host=localhost;dbname=xpdotest;charset=utf8', 'username' => 'test', 'password' => 'test', 'options' => [xPDO::OPT_CONN_MUTABLE => true], 'driverOptions' => []]]]);
$xpdo->setLogLevel(xPDO::LOG_LEVEL_INFO);
$xpdo->setLogTarget();
class modNamespace extends xPDOObject
{
}
class modCategory extends xPDOObject
{
public function getFKDefinition($alias)
{
$aggregates = ['Plugins' => ['class' => 'modPlugin', 'local' => 'id', 'foreign' => 'category', 'cardinality' => 'many', 'owner' => 'local']];
return isset($aggregates[$alias]) ? $aggregates[$alias] : [];
}
}
class modSystemSetting extends xPDOObject
{
示例3: header
$_SESSION['user'] = 1;
if (!isset($_SESSION['user'])) {
if (!$_REQUEST['xoadCall']) {
header('location: login.php');
} else {
echo 'SESSION_TIME_EXPIRED';
die;
}
}
require_once 'inc/core/helpers.php';
require_once 'conf/init.php';
require_once xConfig::get('PATH', 'CORE') . 'core.php';
require_once xConfig::get('PATH', 'CORE') . 'helpers.tpl.php';
xRegistry::set('TMS', $TMS = new tMultiSection());
xPDO::setSource(DB_HOST, DB_NAME, DB_USER, DB_PASS);
xRegistry::set('xPDO', xPDO::getInstance());
xNameSpaceHolder::addObjectToNS('E', new ENHANCE());
require_once xConfig::get('PATH', 'XOAD') . 'xoad.php';
require_once xConfig::get('PATH', 'ADM') . 'logger.class.php';
require_once xConfig::get('PATH', 'ADM') . 'adm.class.php';
if ($_REQUEST['xoadCall']) {
ob_start();
$adm = new adminPanel();
$adm->startMapping();
if (XOAD_Server::runServer()) {
$all = ob_get_contents();
ob_end_clean();
if ($_COMMON_SITE_CONF['output_html_compress']) {
Common::compress_output($all);
}
echo $all;