本文整理汇总了PHP中Sintattica\Atk\Core\Tools::atknotice方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::atknotice方法的具体用法?PHP Tools::atknotice怎么用?PHP Tools::atknotice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sintattica\Atk\Core\Tools
的用法示例。
在下文中一共展示了Tools::atknotice方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
/**
* Get Cache instance, default when no type
* is configured it will use var cache.
*
* @param string $types Cache type
* @param bool $fallback fallback to var cache if all types fail?
* @param bool $force force new instance
*
* @return Cache object of the request type
*
* @throws Exception if $fallback is false and Cache type(s) not found
*/
public static function getInstance($types = '', $fallback = true, $force = false)
{
if ($types == '') {
$types = Config::getGlobal('cache_method', array());
}
if (!is_array($types)) {
$types = array($types);
}
foreach ($types as $type) {
try {
if (!$force && array_key_exists($type, self::$m_instances) && is_object(self::$m_instances[$type])) {
Tools::atkdebug("cache::getInstance -> Using cached instance of {$type}");
return self::$m_instances[$type];
} else {
self::$m_instances[$type] = new $type();
self::$m_instances[$type]->setNamespace(Config::getGlobal('cache_namespace', 'default'));
self::$m_instances[$type]->setLifetime(self::$m_instances[$type]->getCacheConfig('lifetime', 3600));
self::$m_instances[$type]->setActive(Config::getGlobal('cache_active', true));
Tools::atkdebug("cache::getInstance() -> Using {$type} cache");
return self::$m_instances[$type];
}
} catch (Exception $e) {
Tools::atknotice("Can't instantatie atkCache class {$type}: " . $e->getMessage());
}
}
if (!$fallback) {
throw new Exception('Cannot instantiate Cache class of the following type(s): ' . implode(', ', $types));
}
// Default return var cache
Tools::atkdebug('cache::getInstance() -> Using var cache');
return self::getInstance('var', false, $force);
}
示例2: getQueryMode
/**
* Returns the query mode.
*
* @param string $query
*
* @return string Return r or w mode
*/
public function getQueryMode($query)
{
$query = strtolower($query);
$regexes = array('^\\s*select(?!\\s+into)', '^\\s*show');
foreach ($regexes as $regex) {
if (preg_match("/{$regex}/", $query)) {
return 'r';
}
}
Tools::atknotice('Query mode not detected! Using write mode.');
return 'w';
}