本文整理汇总了PHP中Q::getIni方法的典型用法代码示例。如果您正苦于以下问题:PHP Q::getIni方法的具体用法?PHP Q::getIni怎么用?PHP Q::getIni使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Q
的用法示例。
在下文中一共展示了Q::getIni方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadCached
/**
* 载入缓存的 YAML 解析结果,如果缓存失效,则重新解析并生成缓存
*
* @param string $filename
* 要解析的 yaml 文件名
* @param array $replace
* 对于 YAML 内容要进行自动替换的字符串对
* @param string $cache_backend
* 要使用的缓存后端
*
* @return array
* 解析结果
*/
static function loadCached($filename, array $replace = null, $cache_backend = null)
{
static $cache_obj = null;
if (!is_file($filename)) {
throw new QException_FileNotFound($filename);
}
$policy = array('lifetime' => 86400, 'serialize' => true);
$mtime = filemtime($filename);
$id = 'yaml_cache_' . md5($filename);
if (is_null($cache_backend)) {
if (is_null($cache_obj)) {
$cache_obj = Q::getSingleton(Q::getIni('runtime_cache_backend'));
}
$cache = $cache_obj;
} else {
$cache = self::getSingleton($cache_backend);
}
/* @var $cache QCache_File */
$data = $cache->get($id, $policy);
if (!isset($data['yaml']) || empty($data['mtime']) || $data['mtime'] < $mtime) {
// 缓存失效
$data = array('mtime' => $mtime, 'yaml' => self::load($filename, $replace));
$cache->set($id, $data, $policy);
}
return $data['yaml'];
}
示例2: getConn
/**
* 获得一个数据库连接对象
*
* $dsn_name 参数指定要使用应用程序设置中的哪一个项目作为创建数据库连接的 DSN 信息。
* 对于同样的 DSN 信息,只会返回一个数据库连接对象。
*
* @param string $dsn_name
*
* @return QDB_Adapter_Abstract
*/
static function getConn($dsn_name = null)
{
$default = empty($dsn_name);
if ($default && Q::isRegistered('dbo_default')) {
return Q::registry('dbo_default');
}
if (empty($dsn_name)) {
$dsn = Q::getIni('db_dsn_pool/default');
} else {
$dsn = Q::getIni('db_dsn_pool/' . $dsn_name);
}
if (empty($dsn)) {
// LC_MSG: Invalid DSN.
trigger_error('invalid dsn');
throw new QException(__('Invalid DSN.'));
}
$dbtype = $dsn['driver'];
$objid = "dbo_{$dbtype}_" . md5(serialize($dsn));
if (Q::isRegistered($objid)) {
return Q::registry($objid);
}
$class_name = 'QDB_Adapter_' . ucfirst($dbtype);
$dbo = new $class_name($dsn, $objid);
Q::register($dbo, $objid);
if ($default) {
Q::register($dbo, 'dbo_default');
}
return $dbo;
}
示例3: __construct
function __construct()
{
$dsn = Q::getIni('db_dsn_pool/default');
if (empty($dsn)) {
Q::setIni('db_dsn_pool/default', Q::getIni('db_dsn_mysql'));
}
parent::__construct();
}
示例4: __construct
/**
* 构造函数
*
* @param 默认的缓存策略 $default_policy
*/
function __construct(array $default_policy = null)
{
if (!is_null($default_policy)) {
$this->_default_policy = array_merge($this->_default_policy, $default_policy);
}
if (empty($this->_default_policy['cache_dir'])) {
$this->_default_policy['cache_dir'] = Q::getIni('runtime_cache_dir');
}
}
示例5: testUnsetIni
function testUnsetIni()
{
Q::unsetIni('root/node/item');
$test = Q::getIni('root/node');
$this->assertTrue(empty($test), "Q::getIni('root/node') == empty");
Q::unsetIni('root');
$test = Q::getIni('root');
$this->assertTrue(empty($test), "Q::getIni('root') == empty");
}
示例6: setUp
protected function setUp()
{
$dsn = Q::getIni('db_dsn_pool/default');
if (empty($dsn)) {
Q::setIni('db_dsn_pool/default', Q::getIni('db_dsn_mysql'));
}
$this->_conn = QDB::getConn();
$this->_conn->startTrans();
}
示例7: setUp
protected function setUp()
{
$dsn = Q::getIni('db_dsn_pool/default');
if (empty($dsn)) {
Q::setIni('db_dsn_pool/default', Q::getIni('db_dsn_mysql'));
}
$conn = QDB::getConn();
$params = array('name' => 'posts', 'pk' => 'post_id', 'conn' => $conn);
$this->table = new QDB_Table($params);
}
示例8: _setupMeta
/**
* 设置当前数据表的元数据
*/
protected function _setupMeta()
{
$table_name = $this->getFullTableName();
$this->_cache_id = $this->_conn->getID() . '-' . $table_name;
if (isset(self::$_meta[$this->_cache_id])) {
return;
}
$cached = Q::getIni('db_meta_cached');
if ($cached) {
// 尝试从缓存读取
$policy = array('encoding_filename' => true, 'serialize' => true, 'life_time' => Q::getIni('db_meta_lifetime'), 'cache_dir' => Q::getIni('runtime_cache_dir'));
$backend = Q::getIni('db_meta_cache_backend');
$data = Q::getCache($this->_cache_id, $policy, $backend);
if (is_array($data) && !empty($data)) {
self::$_meta[$this->_cache_id] = $data[0];
self::$_fields[$this->_cache_id] = $data[1];
return;
}
}
// 从数据库获得 meta
$meta = $this->_conn->metaColumns($table_name);
$fields = array();
foreach ($meta as $field) {
$fields[$field['name']] = true;
}
self::$_meta[$this->_cache_id] = $meta;
self::$_fields[$this->_cache_id] = $fields;
$data = array($meta, $fields);
if ($cached) {
// 缓存数据
Q::setCache($this->_cache_id, $data, $policy, $backend);
}
}
示例9: while
// $Id$
/**
* @file
* 定义 QView_Adapter_Smarty 类
*
* @ingroup view
*
* @{
*/
// {{{ includes
do {
if (class_exists('Smarty', false)) {
break;
}
$view_config = (array) Q::getIni('view_config');
if (empty($view_config['smarty_dir']) && !defined('SMARTY_DIR')) {
throw new QView_Exception(__('Application settings "view_config[\'smarty_dir\']" ' . 'and constant SMARTY_DIR must be defined for QView_Adapter_Smarty.'));
}
if (empty($view_config['smarty_dir'])) {
$view_config['smarty_dir'] = SMARTY_DIR;
}
Q::loadClassFile('Smarty.class.php', $view_config['smarty_dir'], 'Smarty');
} while (false);
// }}}
/**
* QView_Adapter_Smarty 提供了对 Smarty 模板引擎的支持
*/
class QView_Adapter_Smarty extends QView_Adapter_Abstract
{
public $tpl_file_ext = '.html';
示例10: testGetTablePrefix
function testGetTablePrefix()
{
$prefix = $this->dbo->getTablePrefix();
$this->assertEquals(Q::getIni('db_dsn_pool/default/prefix'), $prefix);
}
示例11: assert
/**
* 断言
*
* 如果 $bool 为 false,则调用 assert() 方法。这会导致一个警告信息或中断执行。
*
* @param boolean $bool
* 断言结果
* @param string $message
* 要显示的断言信息
*/
static function assert($bool, $message = null)
{
if (!self::$_assert_enabled || $bool) {
return;
}
if (self::$_firephp_enabled) {
QDebug_FirePHP::assert($bool, $message);
return;
}
if (Q::getIni('assert_warning')) {
trigger_error($message . "\nAssertion failed", E_USER_WARNING);
self::dumpTrace();
}
if (Q::getIni('assert_exception')) {
throw new QDebug_Assert_Failed($message);
}
}
示例12: append
/**
* 追加日志到日志缓存
*
* @param string $msg
* @param int $type
*/
function append($msg, $type = self::DEBUG)
{
if (!Q::getIni('log_enabled')) {
return;
}
if (isset($this->_priorities['index'][$type])) {
$type_name = $this->_priorities['index'][$type];
} elseif (isset($this->_priorities['names'][$type])) {
$type_name = $type;
$type = $this->_priorities['names'][$type];
} else {
return;
}
$msg = str_replace(array("\n", "\r"), '', $msg);
$this->_log[] = array(time(), $msg, $type, $type_name);
$this->_cached_size += strlen($msg);
unset($msg);
if ($this->_cached_size >= $this->_cache_chunk_size) {
$this->flush();
}
}
示例13: __
/**
* QeePHP 内部使用的多语言翻译函数
*
* 应用程序应该使用 QTranslate 组件实现多语言界面。
*
* @return $msg
*/
function __()
{
$args = func_get_args();
$msg = array_shift($args);
$language = strtolower(Q::getIni('error_language'));
$messages = Q::loadFile('lc_messages.php', Q_DIR . '/_lang/' . $language, false);
if (isset($messages[$msg])) {
$msg = $messages[$msg];
}
array_unshift($args, $msg);
return call_user_func_array('sprintf', $args);
}