本文整理汇总了PHP中throw_exception函数的典型用法代码示例。如果您正苦于以下问题:PHP throw_exception函数的具体用法?PHP throw_exception怎么用?PHP throw_exception使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了throw_exception函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: factory
/**
* 返回工厂实例,单例模式
*/
public static function factory($options)
{
$options = is_array($options) ? $options : array();
//只实例化一个对象
if (is_null(self::$cacheFactory)) {
self::$cacheFactory = new cacheFactory();
}
$driver = isset($options['driver']) ? $options['driver'] : C("CACHE_TYPE");
//静态缓存实例名称
$driverName = md5_d($options);
//对象实例存在
if (isset(self::$cacheFactory->cacheList[$driverName])) {
return self::$cacheFactory->cacheList[$driverName];
}
$class = 'Cache' . ucwords(strtolower($driver));
//缓存驱动
$classFile = HDPHP_DRIVER_PATH . 'Cache/' . $class . '.class.php';
//加载驱动类库文件
if (!require_cache($classFile)) {
throw_exception("缓存类型指定错误,不存在缓存驱动文件:" . $classFile);
}
$cacheObj = new $class($options);
self::$cacheFactory->cacheList[$driverName] = $cacheObj;
return self::$cacheFactory->cacheList[$driverName];
}
开发者ID:sxau-web-team,项目名称:wish-web,代码行数:28,代码来源:CacheFactory.class.php
示例2: connect
/**
* 连接数据库方法
* @access public
* @throws ThinkExecption
*/
public function connect($config = '', $linkNum = 0, $force = false)
{
if (!isset($this->linkID[$linkNum])) {
if (empty($config)) {
$config = $this->config;
}
// 处理不带端口号的socket连接情况
$host = $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : '');
// 是否长连接
$pconnect = !empty($config['params']['persist']) ? $config['params']['persist'] : $this->pconnect;
if ($pconnect) {
$this->linkID[$linkNum] = mysql_pconnect($host, $config['username'], $config['password'], CLIENT_MULTI_RESULTS);
} else {
$this->linkID[$linkNum] = mysql_connect($host, $config['username'], $config['password'], true, CLIENT_MULTI_RESULTS);
}
if (!$this->linkID[$linkNum] || !empty($config['database']) && !mysql_select_db($config['database'], $this->linkID[$linkNum]) || C('SPARE_DB_DEBUG')) {
$errStr = mysql_error();
$errno = mysql_errno();
if ($errno == 13047 || C('SPARE_DB_DEBUG')) {
if (C('SMS_ALERT_ON')) {
Sms::send('mysql超额被禁用,请在SAE日志中心查看详情', $errStr, Sms::MYSQL_ERROR);
}
//[sae]启动备用数据库
if (C('SPARE_DB_HOST')) {
$this->linkID[$linkNum] = mysql_connect(C('SPARE_DB_HOST') . (C('SPARE_DB_PORT') ? ':' . C('SPARE_DB_PORT') : ''), C('SPARE_DB_USER'), C('SPARE_DB_PWD'), true, CLIENT_MULTI_RESULTS);
if (!$this->linkID[$linkNum]) {
throw_exception('备用数据库连接失败');
}
mysql_select_db(C('SPARE_DB_NAME'), $this->linkID[$linkNum]);
//标记使用备用数据库状态
$this->is_spare = true;
} else {
throw_exception($errStr);
}
} else {
//[sae] 短信预警
if (C('SMS_ALERT_ON')) {
Sms::send('数据库连接时出错,请在SAE日志中心查看详情', $errStr, Sms::MYSQL_ERROR);
}
throw_exception($errStr);
}
}
$dbVersion = mysql_get_server_info($this->linkID[$linkNum]);
if ($dbVersion >= '4.1') {
//使用UTF8存取数据库 需要mysql 4.1.0以上支持
mysql_query("SET NAMES '" . C('DB_CHARSET') . "'", $this->linkID[$linkNum]);
}
//设置 sql_model
if ($dbVersion > '5.0.1') {
mysql_query("SET sql_mode=''", $this->linkID[$linkNum]);
}
// 标记连接成功
$this->connected = true;
// 注销数据库连接配置信息
if (1 != C('DB_DEPLOY_TYPE')) {
unset($this->config);
}
}
return $this->linkID[$linkNum];
}
开发者ID:ysking,项目名称:commlib,代码行数:65,代码来源:DbMysql.class.php
示例3: run
public function run(&$_data)
{
$engine = strtolower(C('TMPL_ENGINE_TYPE'));
if ('think' == $engine) {
// 采用Think模板引擎
if ($this->checkCache($_data['file'])) {
// 缓存有效
// 分解变量并载入模板缓存
extract($_data['var'], EXTR_OVERWRITE);
//载入模版缓存文件
include C('CACHE_PATH') . md5($_data['file']) . C('TMPL_CACHFILE_SUFFIX');
} else {
$tpl = Think::instance('ThinkTemplate');
// 编译并加载模板文件
$tpl->fetch($_data['file'], $_data['var']);
}
} else {
// 调用第三方模板引擎解析和输出
$class = 'Template' . ucwords($engine);
if (is_file(CORE_PATH . 'Driver/Template/' . $class . '.class.php')) {
// 内置驱动
$path = CORE_PATH;
} else {
// 扩展驱动
$path = EXTEND_PATH;
}
if (require_cache($path . 'Driver/Template/' . $class . '.class.php')) {
$tpl = new $class();
$tpl->fetch($_data['file'], $_data['var']);
} else {
// 类没有定义
throw_exception(L('_NOT_SUPPERT_') . ': ' . $class);
}
}
}
开发者ID:yunsite,项目名称:e-tuan001-com,代码行数:35,代码来源:ParseTemplateBehavior.class.php
示例4: __construct
public function __construct()
{
if (!extension_loaded('eAccelerator')) {
throw_exception('eAccelerator failed to load');
}
$this->prefix = $this->config['prefix'] ? $this->config['prefix'] : substr(md5($_SERVER['HTTP_HOST']), 0, 6) . '_';
}
开发者ID:norain2050,项目名称:xingkang,代码行数:7,代码来源:cache.eaccelerator.php
示例5: connect
/**
* 连接数据库方法
* @access public
*/
public function connect($config = '', $linkNum = 0)
{
if (!isset($this->linkID[$linkNum])) {
if (empty($config)) {
$config = $this->config;
}
$pconnect = !empty($config['params']['persist']) ? $config['params']['persist'] : $this->pconnect;
$conn = $pconnect ? 'mssql_pconnect' : 'mssql_connect';
// 处理不带端口号的socket连接情况
$sepr = IS_WIN ? ',' : ':';
$host = $config['hostname'] . ($config['hostport'] ? $sepr . "{$config['hostport']}" : '');
$this->linkID[$linkNum] = $conn($host, $config['username'], $config['password']);
if (!$this->linkID[$linkNum]) {
throw_exception("Couldn't connect to SQL Server on {$host}");
}
if (!empty($config['database']) && !mssql_select_db($config['database'], $this->linkID[$linkNum])) {
throw_exception("Couldn't open database '" . $config['database']);
}
// 标记连接成功
$this->connected = true;
//注销数据库安全信息
if (1 != C('DB_DEPLOY_TYPE')) {
unset($this->config);
}
}
return $this->linkID[$linkNum];
}
开发者ID:wjgjb1109,项目名称:huicms,代码行数:31,代码来源:DbMssql.class.php
示例6: connect
/**
* 连接数据库方法
* @access public
*/
public function connect($config = '', $linkNum = 0)
{
if (!isset($this->linkID[$linkNum])) {
if (empty($config)) {
$config = $this->config;
}
$pconnect = !empty($config['params']['persist']) ? $config['params']['persist'] : $this->pconnect;
$conn = $pconnect ? 'pg_pconnect' : 'pg_connect';
$this->linkID[$linkNum] = $conn('host=' . $config['hostname'] . ' port=' . $config['hostport'] . ' dbname=' . $config['database'] . ' user=' . $config['username'] . ' password=' . $config['password']);
if (0 !== pg_connection_status($this->linkID[$linkNum])) {
throw_exception($this->error(false));
}
//设置编码
pg_set_client_encoding($this->linkID[$linkNum], C('DB_CHARSET'));
//$pgInfo = pg_version($this->linkID[$linkNum]);
//$dbVersion = $pgInfo['server'];
// 标记连接成功
$this->connected = true;
//注销数据库安全信息
if (1 != C('DB_DEPLOY_TYPE')) {
unset($this->config);
}
}
return $this->linkID[$linkNum];
}
开发者ID:cnn007,项目名称:FHCRM,代码行数:29,代码来源:DbPgsql.class.php
示例7: run
public function run(&$_data)
{
$engine = strtolower(C('TMPL_ENGINE_TYPE'));
$_content = empty($_data['content']) ? $_data['file'] : $_data['content'];
$_data['prefix'] = !empty($_data['prefix']) ? $_data['prefix'] : C('TMPL_CACHE_PREFIX');
if ('think' == $engine) {
// 采用Think模板引擎
if (!empty($_data['content']) && $this->checkContentCache($_data['content'], $_data['prefix']) || $this->checkCache($_data['file'], $_data['prefix'])) {
// 缓存有效
// 分解变量并载入模板缓存
extract($_data['var'], EXTR_OVERWRITE);
//载入模版缓存文件
include C('CACHE_PATH') . $_data['prefix'] . md5($_content) . C('TMPL_CACHFILE_SUFFIX');
} else {
$tpl = Think::instance('ThinkTemplate');
// 编译并加载模板文件
$tpl->fetch($_content, $_data['var'], $_data['prefix']);
}
} else {
// 调用第三方模板引擎解析和输出
$class = 'Template' . ucwords($engine);
if (class_exists($class)) {
$tpl = new $class();
$tpl->fetch($_content, $_data['var']);
} else {
// 类没有定义
throw_exception(L('_NOT_SUPPERT_') . ': ' . $class);
}
}
}
开发者ID:ljhchshm,项目名称:weixin,代码行数:30,代码来源:ParseTemplateBehavior.class.php
示例8: __construct
public function __construct()
{
if (!function_exists("xcache_info")) {
throw_exception("Xcache failed to load");
}
$this->prefix = $this->config['prefix'] ? $this->config['prefix'] : substr(md5($_SERVER['HTTP_HOST']), 0, 6) . "_";
}
开发者ID:my1977,项目名称:shopnc,代码行数:7,代码来源:cache.xcache.php
示例9: connect
/**
* 连接
* @access public
* @param array $options 配置数组
* @return object
*/
public static function connect($options = array())
{
if (isset($options['type']) && $options['type']) {
$type = $options['type'];
unset($options['type']);
} else {
//网站配置
$config = F("Config");
if ((int) $config['ftpstatus']) {
$type = 'Ftp';
} else {
$type = 'Local';
}
}
//附件存储方案
$type = trim($type);
$class = 'Attachment' . ucwords($type);
import("Driver.Attachment.{$class}", LIB_PATH);
if (class_exists($class)) {
$Atta = new $class($options);
} else {
throw_exception('无法加载附件上传方案:' . $type);
}
return $Atta;
}
开发者ID:NeilFee,项目名称:vipxinbaigo,代码行数:31,代码来源:AttachmentService.class.php
示例10: login
public function login()
{
if (is_empty($this->post->user) || is_empty($this->post->password)) {
throw_exception("User and Password are required");
}
$options['user']['lvl2'] = "one_login";
$cod['user']['user'] = $this->post->user;
$cod['user']['password'] = $this->post->password;
$this->orm->connect();
$this->orm->read_data(array("user"), $options, $cod);
$user = $this->orm->get_objects("user");
#echo $user[0]->get('type');
$this->orm->close();
if (is_empty($user)) {
throw_exception("User or Password Incorrect");
} else {
$_SESSION['user']['id'] = $user[0]->get('id');
$_SESSION['user']['name'] = $user[0]->get('name');
$_SESSION['user']['user'] = $user[0]->get('user');
$_SESSION['user']['type'] = $user[0]->get('type');
$_SESSION['user']['email'] = $user[0]->get('email');
$this->session = $_SESSION;
$this->engine->assign('type_warning', 'success');
$this->engine->assign('msg_warning', "Welcome!");
$this->temp_aux = 'message.tpl';
}
}
开发者ID:ancdiazmo,项目名称:ghost_mi_version,代码行数:27,代码来源:index.php
示例11: connect
/**
* Connection database method
* @access public
* @throws SenExecption
*/
public function connect($config = '', $linkNum = 0)
{
if (!isset($this->linkID[$linkNum])) {
if (empty($config)) {
$config = $this->config;
}
$this->linkID[$linkNum] = new mysqli($config['hostname'], $config['username'], $config['password'], $config['database'], $config['hostport'] ? intval($config['hostport']) : 3306);
if (mysqli_connect_errno()) {
throw_exception(mysqli_connect_error());
}
$dbVersion = $this->linkID[$linkNum]->server_version;
// Set the database encoding
$this->linkID[$linkNum]->query("SET NAMES '" . C('DB_CHARSET') . "'");
//Setup sql_model
if ($dbVersion > '5.0.1') {
$this->linkID[$linkNum]->query("SET sql_mode=''");
}
// Mark connection successful
$this->connected = true;
//Unregister database security information
if (1 != C('DB_DEPLOY_TYPE')) {
unset($this->config);
}
}
return $this->linkID[$linkNum];
}
开发者ID:davidpersson,项目名称:FrameworkBenchmarks,代码行数:31,代码来源:DbMysqli.class.php
示例12: run
public function run(&$_data)
{
$engine = strtolower(C('TMPL_ENGINE_TYPE'));
$_content = empty($_data['content']) ? $_data['file'] : $_data['content'];
$_data['prefix'] = !empty($_data['prefix']) ? $_data['prefix'] : C('TMPL_CACHE_PREFIX');
if ('think' == $engine) {
//[sae] 采用Think模板引擎
if (!empty($_data['content']) && $this->checkContentCache($_data['content'], $_data['prefix']) || $this->checkCache($_data['file'], $_data['prefix'])) {
// 缓存有效
//[sae],为方便saeCacheBuilder编译, 模板编译缓存不分组
SaeMC::include_file(C('CACHE_PATH') . $_data['prefix'] . md5($_content) . C('TMPL_CACHFILE_SUFFIX'), $_data['var']);
} else {
$tpl = Think::instance('ThinkTemplate');
// 编译并加载模板文件
$tpl->fetch($_content, $_data['var'], $_data['prefix']);
}
} else {
// 调用第三方模板引擎解析和输出
$class = 'Template' . ucwords($engine);
if (class_exists($class)) {
$tpl = new $class();
$tpl->fetch($_content, $_data['var']);
} else {
// 类没有定义
throw_exception(L('_NOT_SUPPERT_') . ': ' . $class);
}
}
//[sae] 添加trace信息。
if (!SAE_RUNTIME) {
trace($_SERVER['HTTP_APPVERSION'] . '/' . RUNTIME_FILE, '核心缓存Mecache KEY', 'SAE');
trace($_SERVER['HTTP_APPVERSION'] . '/' . C('CACHE_PATH') . $_data['prefix'] . md5($_content) . C('TMPL_CACHFILE_SUFFIX'), '模版缓存Mecache KEY', 'SAE');
}
}
开发者ID:jackycgq,项目名称:extend,代码行数:33,代码来源:ParseTemplateBehavior.class.php
示例13: agregar
public function agregar()
{
$parque = new parque($this->post);
if (is_empty($parque->get('codigo'))) {
throw_exception("Debe ingresar un codigo");
}
if ($parque->get("nivel") == "alto" || $parque->get("nivel") == "bajo") {
} else {
throw_exception("El nivel debe de ser alto o bajo");
}
if ($parque->get("municipio") == "medellin" || $parque->get("municipio") == "rionegro" || $parque->get("municipio") == "la estrella" || $parque->get(" municipio") == "copacabana" || $parque->get(" municipio") == "guatape") {
} else {
throw_exception("El municipio debe de ser medellin, rionegro, la estrella, copacabana o guatape");
}
print_r($parque);
$this->orm->connect();
$this->orm->insert_data("normal", $parque);
$this->orm->close();
settype($data, 'object');
$data->fecha = date("y-m-d");
$data->calificacion = 0;
$data->parque = $parque->get("codigo");
$calificacion = new calificacion($data);
$this->orm->connect();
$this->orm->insert_data("normal", $calificacion);
$this->orm->close();
$this->type_warning = "sucess";
$this->msg_warning = "parque agregado correctamente";
$this->temp_aux = 'message.tpl';
$this->engine->assign('type_warning', $this->type_warning);
$this->engine->assign('msg_warning', $this->msg_warning);
}
开发者ID:Gonzo107,项目名称:Parcial2AndresGonzalez,代码行数:32,代码来源:c_agregar_parque.php
示例14: CheckCache
/**
+----------------------------------------------------------
* 缓存检查
* 缓存目录创建、目录权限检查
+----------------------------------------------------------
* @access private
+----------------------------------------------------------
* @return void
+----------------------------------------------------------
*/
function CheckCache()
{
//检测模版缓存目录,并尝试创建
if (!file_exists(CACHE_PATH)) {
if (!@mkdir(CACHE_PATH)) {
throw_exception(L('模版缓存目录不存在:') . CACHE_PATH);
}
}
//检测数据缓存目录,并尝试创建
if (!file_exists(TEMP_PATH)) {
if (!@mkdir(TEMP_PATH)) {
throw_exception(L('数据缓存目录不存在:') . TEMP_PATH);
}
}
//检测静态缓存目录,并尝试创建
if (!file_exists(HTML_PATH)) {
if (!@mkdir(HTML_PATH)) {
throw_exception(L('静态缓存目录不存在:') . HTML_PATH);
}
}
//检测日志目录,并尝试创建
if (!file_exists(LOG_PATH)) {
if (!@mkdir(LOG_PATH)) {
throw_exception(L('日志目录不存在:') . LOG_PATH);
}
}
return;
}
开发者ID:skiman100,项目名称:thinksns,代码行数:38,代码来源:checkDir.php
示例15: __construct
public function __construct(){
$this->config = C('memcache');
if (!extension_loaded('memcache') || !is_array($this->config[1])) {
throw_exception('memcache failed to load');
}
$this->init();
}
开发者ID:noikiy,项目名称:ejia,代码行数:7,代码来源:cache.memcache.php
示例16: __construct
/**
* 架构函数
* @param array $options 缓存参数
* @access public
*/
function __construct($options = array())
{
if (!extension_loaded('memcached')) {
throw_exception(L('_NOT_SUPPERT_') . ':memcached');
}
if (empty($options)) {
$options = array('host' => C('MEMCACHE_HOST') ? C('MEMCACHE_HOST') : '127.0.0.1', 'port' => C('MEMCACHE_PORT') ? C('MEMCACHE_PORT') : 11211, 'weight' => C('MEMCACHE_WEIGHT') ? C('MEMCACHE_WEIGHT') : 0, 'timeout' => C('DATA_CACHE_TIMEOUT') ? C('DATA_CACHE_TIMEOUT') : false, 'compress' => C('DATA_CACHE_COMPRESS') ? C('DATA_CACHE_COMPRESS') : false, 'persistent' => false);
}
$this->options = $options;
$this->options['expire'] = isset($options['expire']) ? $options['expire'] : C('DATA_CACHE_TIME');
$this->options['prefix'] = isset($options['prefix']) ? $options['prefix'] : C('DATA_CACHE_PREFIX');
$this->options['length'] = isset($options['length']) ? $options['length'] : 0;
$func = $options['persistent'] ? 'pconnect' : 'connect';
$key = $this->options['host'] . $this->options['port'];
$this->handler = new Memcached($key);
if (!count($this->handler->getServerList())) {
//This code block will only execute if we are setting up a new EG(persistent_list) entry
$this->handler->setOption(Memcached::OPT_RECV_TIMEOUT, $this->options['timeout']);
$this->handler->setOption(Memcached::OPT_SEND_TIMEOUT, $this->options['timeout']);
$this->handler->setOption(Memcached::OPT_COMPRESSION, $this->options['compress']);
$this->handler->setOption(Memcached::OPT_TCP_NODELAY, true);
$this->handler->setOption(Memcached::OPT_PREFIX_KEY, $this->options['prefix']);
$this->connected = $this->handler->addServer($this->options['host'], $this->options['port']);
}
}
开发者ID:NTASTE,项目名称:wms,代码行数:30,代码来源:CacheMemcached.class.php
示例17: parseTemplateFile
/**
* 自动定位模板文件
* @access private
* @param string $templateFile 文件名
* @return string
*/
private function parseTemplateFile($templateFile)
{
if ('' == $templateFile) {
// 如果模板文件名为空 按照默认规则定位
$templateFile = C('TEMPLATE_NAME');
} elseif (false === strpos($templateFile, C('TMPL_TEMPLATE_SUFFIX'))) {
// 解析规则为 分组@模板主题:模块:操作
if (strpos($templateFile, '@')) {
list($group, $templateFile) = explode('@', $templateFile);
if (1 == C('APP_GROUP_MODE')) {
$basePath = dirname(BASE_LIB_PATH) . '/';
} else {
$basePath = TMPL_PATH;
}
$basePath .= $group . '/' . basename(TMPL_PATH) . '/' . (THEME_NAME ? THEME_NAME . '/' : '');
} else {
$basePath = THEME_PATH;
}
$path = explode(':', $templateFile);
$action = array_pop($path);
$module = !empty($path) ? array_pop($path) : MODULE_NAME;
if (!empty($path)) {
// 设置模板主题
$basePath = dirname($basePath) . '/' . array_pop($path) . '/';
}
$templateFile = $basePath . $module . C('TMPL_FILE_DEPR') . $action . C('TMPL_TEMPLATE_SUFFIX');
}
if (!file_exists_case($templateFile)) {
throw_exception(L('_TEMPLATE_NOT_EXIST_') . '[' . $templateFile . ']');
}
return $templateFile;
}
开发者ID:omusico,项目名称:MRFOS,代码行数:38,代码来源:LocationTemplateBehavior.class.php
示例18: connect
/**
* Connection database method
* @access public
* @throws SenExecption
*/
public function connect($config = '', $linkNum = 0, $force = false)
{
if (!isset($this->linkID[$linkNum])) {
if (empty($config)) {
$config = $this->config;
}
// Deal with the port number of the socket connection
$host = $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : '');
// Whether long connection
$pconnect = !empty($config['params']['persist']) ? $config['params']['persist'] : $this->pconnect;
if ($pconnect) {
$this->linkID[$linkNum] = mysql_pconnect($host, $config['username'], $config['password'], 131072);
} else {
$this->linkID[$linkNum] = mysql_connect($host, $config['username'], $config['password'], true, 131072);
}
if (!$this->linkID[$linkNum] || !empty($config['database']) && !mysql_select_db($config['database'], $this->linkID[$linkNum])) {
throw_exception(mysql_error());
}
$dbVersion = mysql_get_server_info($this->linkID[$linkNum]);
//Access database using UTF8
mysql_query("SET NAMES '" . C('DB_CHARSET') . "'", $this->linkID[$linkNum]);
//Setup sql_model
if ($dbVersion > '5.0.1') {
mysql_query("SET sql_mode=''", $this->linkID[$linkNum]);
}
// Mark connection successful
$this->connected = true;
// Unregister database connection configuration information
if (1 != C('DB_DEPLOY_TYPE')) {
unset($this->config);
}
}
return $this->linkID[$linkNum];
}
开发者ID:davidpersson,项目名称:FrameworkBenchmarks,代码行数:39,代码来源:DbMysql.class.php
示例19: connect
/**
* 连接数据库方法
* @access public
* @throws ThinkExecption
*/
public function connect($config = '', $linkNum = 0, $force = false)
{
if (!isset($this->linkID[$linkNum])) {
if (empty($config)) {
$config = $this->config;
}
// 处理不带端口号的socket连接情况
$host = $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : '');
// 是否长连接
$pconnect = !empty($config['params']['persist']) ? $config['params']['persist'] : $this->pconnect;
if ($pconnect) {
$this->linkID[$linkNum] = mysql_pconnect($host, $config['username'], $config['password'], 131072);
} else {
$this->linkID[$linkNum] = mysql_connect($host, $config['username'], $config['password'], true, 131072);
}
if (!$this->linkID[$linkNum] || !empty($config['database']) && !mysql_select_db($config['database'], $this->linkID[$linkNum])) {
throw_exception(mysql_error());
}
$dbVersion = mysql_get_server_info($this->linkID[$linkNum]);
//使用UTF8存取数据库
mysql_query("SET NAMES '" . C('DB_CHARSET') . "'", $this->linkID[$linkNum]);
//设置 sql_model
if ($dbVersion > '5.0.1') {
mysql_query("SET sql_mode=''", $this->linkID[$linkNum]);
}
// 标记连接成功
$this->connected = true;
// 注销数据库连接配置信息
if (1 != C('DB_DEPLOY_TYPE')) {
unset($this->config);
}
}
return $this->linkID[$linkNum];
}
开发者ID:denson7,项目名称:phpstudy,代码行数:39,代码来源:DbMysql.class.php
示例20: run
public function run(&$_data)
{
$engine = strtolower(C('TMPL_ENGINE_TYPE'));
$_content = empty($_data['content']) ? $_data['file'] : $_data['content'];
$_data['prefix'] = !empty($_data['prefix']) ? $_data['prefix'] : C('TMPL_CACHE_PREFIX');
if ('think' == $engine) {
// 采用Think模板引擎
if (!empty($_data['content']) && $this->checkContentCache($_data['content'], $_data['prefix']) || $this->checkCache($_data['file'], $_data['prefix'])) {
// 缓存有效
//[cluster]载入模版缓存文件
ThinkFS::include_file(C('CACHE_PATH') . $_data['prefix'] . md5($_content) . C('TMPL_CACHFILE_SUFFIX'), $_data['var']);
} else {
$tpl = Think::instance('ThinkTemplate');
// 编译并加载模板文件
$tpl->fetch($_content, $_data['var'], $_data['prefix']);
}
} else {
// 调用第三方模板引擎解析和输出
$class = 'Template' . ucwords($engine);
if (class_exists($class)) {
$tpl = new $class();
$tpl->fetch($_content, $_data['var']);
} else {
// 类没有定义
throw_exception(L('_NOT_SUPPERT_') . ': ' . $class);
}
}
//[cluster] 增加有用的trace信息
trace(RUNTIME_FILE, '核心编译缓存KEY', 'DEBUG');
trace(C('CACHE_PATH') . $_data['prefix'] . md5($_content) . C('TMPL_CACHFILE_SUFFIX'), '模板缓存KEY', 'DEBUG');
}
开发者ID:xibaachao,项目名称:1bz,代码行数:31,代码来源:ParseTemplateBehavior.class.php
注:本文中的throw_exception函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论