本文整理汇总了PHP中herosphp\core\Loader类的典型用法代码示例。如果您正苦于以下问题:PHP Loader类的具体用法?PHP Loader怎么用?PHP Loader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Loader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* 初始化数据库连接
* @param string $table 数据表
* @param array $config 数据库配置信息
*/
public function __construct($table, $config = null)
{
//加载数据表配置
$dbConfigPath = 'db';
if (DB_CFG_PATH != false) {
$dbConfigPath = DB_CFG_PATH;
}
$tableConfig = Loader::config('table', $dbConfigPath);
$this->table = $tableConfig[$table];
//初始化数据库配置
if (!$config) {
//默认使用第一个数据库服务器配置
$dbConfigs = Loader::config('hosts', $dbConfigPath);
$db_config = $dbConfigs[DB_TYPE];
if (DB_ACCESS == DB_ACCESS_SINGLE) {
//单台服务器
$config = $db_config[0];
} else {
if (DB_ACCESS == DB_ACCESS_CLUSTERS) {
//多台服务器
$config = $db_config;
}
}
}
//创建数据库
$this->db = DBFactory::createDB(DB_ACCESS, $config);
}
开发者ID:jifangshiyanshi,项目名称:tuonews,代码行数:32,代码来源:C_Model.class.php
示例2: index
public function index(HttpRequest $request)
{
print_r($request->getParameter());
////----DB 操作
//DB: 原生query操作
$model = Loader::model('user');
$result = $model->query("select * from user");
$rowArr = $result->fetchAll();
print_r($rowArr);
//DB: 查询
//DB: 插入
/*
$data = array(
"id" => "",
"name" => "xm"
);
$model->insert($data);
*/
//DB: 更新
$data = array("id" => "12", "name" => "yy");
$id = 2;
$model->update($data, $id);
//DB: 删除
$id = 1;
$model->delete($id);
//DB: 事物
$items = array("id" => 1, "title" => "hello title2");
$this->assign('items', $items);
$this->assign('var1', "yu");
//$this->display('index_test2');//这里不要用display这个方法,流程不对,用view
$this->setView('index_test');
//die();
}
开发者ID:cqmyg,项目名称:herosphp2,代码行数:33,代码来源:UserAction.class.php
示例3: run
public function run()
{
tprintOk("Hello, world!");
$model = Loader::model('article');
$conditions = array("id" => ">300");
$items = $model->getItems($conditions, "id, url, title", null, 1, 20);
tprintOk($items[0]['title']);
}
开发者ID:cqmyg,项目名称:herosphp2,代码行数:8,代码来源:TestTask.class.php
示例4: delete
/**
* @param HttpRequest $request
*/
public function delete(HttpRequest $request)
{
$id = $request->getParameter('id', 'intval');
$model = Loader::model('article');
if ($id > 0) {
var_dump($model->delete($id));
}
die;
}
开发者ID:yangjian102621,项目名称:herosphp,代码行数:12,代码来源:ArticleAction.class.php
示例5: __construct
/**
* 初始化数据库连接
* @param string $table 数据表
* @param array $config 数据库配置信息
*/
public function __construct($table, $config = null)
{
//初始化数据库配置
if (!$config) {
$congfig = Loader::config('db');
}
//创建数据库
$this->db = DBFactory::createDB('mongo', $congfig['mongo']);
$this->table = $table;
}
开发者ID:yangjian102621,项目名称:herosphp,代码行数:15,代码来源:MongoModel.class.php
示例6: createDB
/**
* 创建数据库连接实例
* @param int $accessType 连接方式(连接单个服务器还是连接集群)
* @param array $config 数据库的配置信息
* @return Idb
*/
public static function createDB($accessType = DB_ACCESS_SINGLE, &$config = null)
{
//获取包含路径
$classPath = self::$DB_DRIVER[$accessType]['path'];
Loader::import($classPath, IMPORT_FRAME);
$className = self::$DB_DRIVER[$accessType]['class'];
$key = md5($className . $config['flag']);
if (!isset(self::$DB_POOL[$key])) {
self::$DB_POOL[$key] = new $className($config);
}
return self::$DB_POOL[$key];
}
开发者ID:yangjian102621,项目名称:herosphp,代码行数:18,代码来源:DBFactory.class.php
示例7: getInstance
/**
* @return bool|null|\Redis
*/
public static function getInstance()
{
if (is_null(self::$redis)) {
$configs = Loader::config('redis', 'cache');
if (!$configs) {
return false;
}
self::$redis = new \Redis();
self::$redis->connect($configs['host'], $configs['port']);
}
return self::$redis;
}
开发者ID:yangjian102621,项目名称:herosphp,代码行数:15,代码来源:RedisUtils.class.php
示例8: permission
/**
* 更改角色权限
* @param HttpRequest $request
*/
public function permission(HttpRequest $request)
{
$id = $request->getParameter('id', 'intval');
if ($id <= 0) {
$this->showMessage('danger', '参数不合法!');
}
$service = Beans::get($this->getServiceBean());
$item = $service->getItem($id);
$permissions = cn_json_decode($item['permissions']);
//加载权限选项
$permissionOptions = Loader::config('admin', 'permission');
$this->assign('permissions', $permissions);
$this->assign('permissionOptions', $permissionOptions);
$this->assign('item', $item);
$this->setView('admin/role_permission');
}
开发者ID:jifangshiyanshi,项目名称:tuonews,代码行数:20,代码来源:RoleAction.class.php
示例9: create
/**
* 创建缓存
* @param $key
* @param bool $single 是否单例模式
* @return \herosphp\cache\interfaces\ICache
*/
public static function create($key = 'file', $single = true)
{
//如果缓存对象已经创建,则则直接返回
if (isset(self::$CACHE_SET[$key]) && $single == false) {
return self::$CACHE_SET[$key];
}
$configs = Loader::config($key, 'cache');
$className = self::$CACHE_BEAN[$key]['class'];
Loader::import(self::$CACHE_BEAN[$key]['path'], IMPORT_FRAME);
if ($single) {
self::$CACHE_SET[$key] = new $className($configs);
return self::$CACHE_SET[$key];
} else {
return $className($configs);
}
}
开发者ID:cqmyg,项目名称:herosphp2,代码行数:22,代码来源:CacheFactory.class.php
示例10: get
/**
* 获取指定ID的Bean
* @param string $key Bean的key
* @param boolean $new 是否创建新的bean,新创建的Bean不会放到容器中,如果要放到容器中,请使用set方法。
* @return Object 返回指定ID的Bean,如果Bean不存在则返回null
*/
public static function get($key, $new = false)
{
if (empty(self::$CONFIGS)) {
self::$CONFIGS = Loader::config('*', 'beans');
if (!self::$CONFIGS) {
return null;
}
}
$beanConfig = self::$CONFIGS[$key];
if ($new || $beanConfig['@single'] === false) {
return self::build($beanConfig);
}
if (!isset(self::$BEAN_POOL[$key])) {
self::$BEAN_POOL[$key] = self::build($beanConfig);
}
return self::$BEAN_POOL[$key];
}
开发者ID:cqmyg,项目名称:herosphp2,代码行数:23,代码来源:Beans.class.php
示例11: run
public function run()
{
// $lock = SynLockFactory::getFileSynLock(0x1234);
// tprintError("try to get the lock....");
// $lock->tryLock();
// tprintOk("get the lock.");
// sleep(10);
// tprintWarning("release the lock.");
// $lock->unlock();
$model = Loader::model("news");
$timer = timer();
for ($i = 0; $i < 1000000; $i++) {
$data = array('name' => 'xiaoming', 'pass' => 'xiaoming_pass', 'address' => 'china ShenZhen');
$model->insert($data);
}
tprintOk("插入完成,耗时:" . (timer() - $timer) . " 秒");
}
开发者ID:yangjian102621,项目名称:herosphp,代码行数:17,代码来源:TestTask.class.php
示例12: start
/**
* 开启session
*/
public static function start()
{
//如果已经开启了SESSION则直接返回
if (isset($_SESSION)) {
return true;
}
//loading session configures
$configs = Loader::config('session', 'session');
switch (SESSION_HANDLER) {
case 'file':
FileSession::start($configs[SESSION_HANDLER]);
break;
case 'memo':
MemSession::start($configs[SESSION_HANDLER]);
break;
}
}
开发者ID:cqmyg,项目名称:herosphp2,代码行数:20,代码来源:Session.class.php
示例13: html
public function html(HttpRequest $request)
{
$CACHER = CacheFactory::create('html');
$CACHER->baseKey('article')->ftype('detail')->factor('299');
$item = $CACHER->get(null);
if (!$item) {
$model = Loader::model('article');
$item = $model->getItem(299);
$this->assign('item', $item);
$html = $this->getExecutedHtml();
if ($CACHER->set(null, $html)) {
__print("生成静态缓存成功!");
}
} else {
echo $item;
}
die;
}
开发者ID:cqmyg,项目名称:herosphp2,代码行数:18,代码来源:CacheAction.class.php
示例14: edit
/**
* 编辑媒体管理员角色界面
* @param HttpRequest $request
*/
public function edit(HttpRequest $request)
{
parent::edit($request);
$item = $this->getTemplateVar('item');
//获取媒体类型
$mediaTypeService = Beans::get('media.type.service');
$mediaType = $mediaTypeService->getItem($item['media_type']);
$permissionTpl = $mediaType['permission_tpl'];
//加载权限选项
$permissions = Loader::config($permissionTpl, 'permission');
$this->assign('permissions', $permissions);
$item['permission'] = cn_json_decode($item['permission']);
$this->assign('item', $item);
$this->assign("seoTitle", "媒体中心后台管理-角色编辑");
$this->assign("seoDesc", "角色管理-角色编辑");
$this->assign("seoKwords", "媒体中心后台管理 角色管理 角色编辑");
$this->setView('role/add');
}
开发者ID:jifangshiyanshi,项目名称:tuonews,代码行数:22,代码来源:ManagerRoleAction.class.php
示例15: builtInstance
/**
* 创建Bean实例
* @param string $classPath 要创建的对象的类路径
* @param array $params 参数列表,可以是数组或者单个参数
* @return object|ReflectionClass
* @throws \Exception
*/
public static function builtInstance($classPath, $params = null)
{
if (!is_string($classPath)) {
return null;
}
try {
$importPath = str_replace('\\', '.', $classPath);
Loader::import($importPath, IMPORT_APP, EXT_PHP);
$instance = new ReflectionClass($classPath);
if (is_array($params)) {
return $instance->newInstanceArgs($params);
} elseif ($params) {
return $instance->newInstance($params);
} else {
return $instance->newInstance();
}
} catch (\Exception $e) {
E($e->getMessage());
}
}
开发者ID:cqmyg,项目名称:herosphp2,代码行数:27,代码来源:BeanUtil.class.php
示例16: __construct
/**
* 初始化数据库连接
* @param string $table 数据表
* @param array $config 数据库配置信息
*/
public function __construct($table, $config = null)
{
//初始化数据库配置
if (!$config) {
//默认使用第一个数据库服务器配置
$dbConfigs = Loader::config('db');
$db_config = $dbConfigs[DB_TYPE];
if (DB_ACCESS == DB_ACCESS_SINGLE) {
//单台服务器
$config = $db_config[0];
} else {
if (DB_ACCESS == DB_ACCESS_CLUSTERS) {
//多台服务器
$config = $db_config;
}
}
}
$this->table = $config['table_prefix'] . $table;
//创建数据库
$this->db = DBFactory::createDB(DB_ACCESS, $config);
}
开发者ID:cqmyg,项目名称:herosphp2,代码行数:26,代码来源:C_Model.class.php
示例17: start
/**
* 开启session
*/
public static function start()
{
//如果已经开启了SESSION则直接返回
if (isset($_SESSION)) {
return true;
}
//loading session configures
$configs = Loader::config('session');
$session_configs = $configs[$configs['session_handler']];
switch ($configs['session_handler']) {
case 'file':
FileSession::start($session_configs);
break;
case 'memo':
MemSession::start($session_configs);
break;
case 'redis':
RedisSession::start($session_configs);
break;
}
}
开发者ID:yangjian102621,项目名称:herosphp,代码行数:24,代码来源:Session.class.php
示例18: index
/**
* 文章推荐位列表
* @param HttpRequest $request
*/
public function index(HttpRequest $request)
{
$__configs = Loader::config('media', 'data');
$service = Beans::get($this->getServiceBean());
$condi = array('media_id' => $this->loginMedia['id']);
$items = $service->getItems($condi);
$items = ArrayUtils::changeArrayKey($items, 'position');
$__configs = $__configs['media_article_rec'];
$__items = array();
foreach ($__configs as $key => $value) {
$__items[$key]['name'] = $value;
$__items[$key]['id'] = $key;
//判断是否开启此推荐位
if (!empty($items[$key])) {
$__items[$key]['open'] = $items[$key]['status'];
} else {
$__items[$key]['open'] = 0;
}
}
$this->assign('items', $__items);
$this->assign("seoTitle", "媒体中心后台管理-文章推荐位");
$this->setView('article/recommend_index');
}
开发者ID:jifangshiyanshi,项目名称:tuonews,代码行数:27,代码来源:ArticleRecAction.class.php
示例19: index
/**
* 首页方法
* @param HttpRequest $request
*/
public function index(HttpRequest $request)
{
$page = $request->getParameter('page', 'intval');
$pagesize = 10;
if ($page <= 0) {
$page = 1;
}
$model = Loader::model('article');
$conditions = array("id" => ">300");
$total = $model->count($conditions);
$items = $model->getItems($conditions, "id, url, title", null, $page, $pagesize);
//初始化分页类
$pageHandler = new Page($total, $pagesize, $page);
//获取分页数据
$pageData = $pageHandler->getPageData(DEFAULT_PAGE_STYLE);
//组合分页HTML代码
if ($pageData) {
$pagemenu = '<ul class="pagination">';
$pagemenu .= '<li><a href="' . $pageData['prev'] . '" aria-label="Previous"><span aria-hidden="true">«</span></a></li>';
foreach ($pageData['list'] as $key => $value) {
if ($key == $page) {
$pagemenu .= '<li class="active"><a href="#fakelink">' . $key . '</a></li> ';
} else {
$pagemenu .= '<li><a href="' . $value . '">' . $key . '</a></li> ';
}
}
$pagemenu .= '<li><a href="' . $pageData['next'] . '" aria-label="Next"><span aria-hidden="true">»</span></a></li>';
$pagemenu .= '</ul>';
$pagemenu .= '<div class="page-input"><input type="text" class="form-control input-sm" value="' . $this->page . '"> ';
$pagemenu .= '<a href="javascript:void(0);" class="btn btn-primary btn-sm" url="' . $pageData['url'] . '" id="page-goto">确定</a></div> ';
}
$this->assign('pagemenu', $pagemenu);
$this->assign('items', $items);
//设置视图
$this->setView('article_page');
}
开发者ID:cqmyg,项目名称:herosphp2,代码行数:40,代码来源:PageAction.class.php
示例20:
<?php
namespace media\service\interfaces;
use common\service\interfaces\ICommonService;
use herosphp\core\Loader;
Loader::import('common.service.interfaces.ICommonService', IMPORT_APP);
/**
* 媒体类型服务接口
* Interface IMediaTypeService
*/
interface IMediaTypeService extends ICommonService
{
}
开发者ID:jifangshiyanshi,项目名称:tuonews,代码行数:14,代码来源:IMediaTypeService.class.php
注:本文中的herosphp\core\Loader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论