本文整理汇总了PHP中herosphp\core\Loader::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Loader::model方法的具体用法?PHP Loader::model怎么用?PHP Loader::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类herosphp\core\Loader
的用法示例。
在下文中一共展示了Loader::model方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: 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']);
}
示例3: 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;
}
示例4: 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) . " 秒");
}
示例5: 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;
}
示例6: 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');
}
示例7: __construct
public function __construct($articleModel, $dataModel)
{
$this->setModelDao(Loader::model($articleModel));
$this->dataDao = Loader::model($dataModel);
}
示例8: __construct
/**
* 构造函数,初始化modelDao
* @param $model
*/
public function __construct($model)
{
$this->setModelDao(Loader::model($model));
}
示例9: mongo
public function mongo()
{
$model = Loader::model("news");
//添加数据 C_Model::insert();
// $address = array('东莞','深圳','广州','北京','上海','杭州');
// for ( $i = 0; $i < 100; $i++ ) {
// $data = array(
// "id" => StringUtils::genGlobalUid(true),
// "name" => "user_{$i}",
// "age" => $i,
// "address" => $address[mt_rand(0,5)]);
//
// __print($model->insert($data));
// }
//C_Model::query();
// $list = $model->query("select * from fiidee_user order by id desc limit 20");
// __print($list);
$id = 'B21A-57B319E4-0269D8C0-D5CB-8295ECE2';
//C_Model::getItem()
// $one = $model->getItem($id);
// __print($one);
//C_Model::delete()
// $model->delete($id);
// __print($model->getItem($id));
//C_Model::deletes()
// $conditions = array(
// 'name' => 'user_1',
// '$or' => array('id' => array('$in' => array('B21A-57B319E4-026B4D68-F5E5-9DF9281A', 'B21A-57B319E4-026C46A0-248C-1907B7D3')))
// );
// var_dump($model->deletes($conditions));
//C_Model::find
// $gets = array('id', 'name', 'address');
// $sort = array('name' => 1);
// $list = $model->where()
// ->field($gets)
// ->sort($sort)
// ->limit(0, 20)
// ->find();
// __print($list);
//C_Model::update
// $data = array(
// 'name' => 'xiaoming',
// 'age' => 30,
// 'address' => '我爱北京天安门'
// );
// $conditions = array('id' => 'B21A-57B319E4-026D4230-E18D-817D454C');
// $model->updates($data, $conditions);
// __print($model->where($conditions)->findOne());
//C_Model::count
// $conditions = array('id' => '>B21A-57B30872-01655B98-538F-FBED5277');
// var_dump($model->count($conditions));
//C_Model::increase
// $condition = array('id' => array('$in' => array('B21A-57B319E4-026DA5CC-79FC-091DB526', 'B21A-57B319E4-026BC748-7837-42B51E30')));
// $model->batchIncrease('age', 10, $condition);
// //$model->batchReduce('age', 10, $condition);
// __print($model->getItems($condition));
//C_Model::set
// $condition = array('id' => array('$in' => array('B21A-57B319E4-026DA5CC-79FC-091DB526', 'B21A-57B319E4-026BC748-7837-42B51E30')));
// $model->sets('age', 200, $condition);
// $model->sets('name', "超级无敌美少女", $condition);
// __print($model->getItems($condition));
// $conditions = array('name' => array('$like' => 'user_1'));
// __print($model->getItems($conditions));
//分组查询
$keys = array("address" => 1);
$initial = array("items" => array());
$reduce = "function (obj, prev) { prev.items.push({id:obj.id, name:obj.name, age:obj.age}); }";
$conditions = array('age' => '>30');
$items = $model->findByGroup($keys, $initial, $reduce, $conditions);
__print($items);
AjaxResult::ajaxSuccessResult();
}
示例10: __construct
/**
* @param $tagModel
* @param $tagAssoc
*/
public function __construct($tagModel, $tagAssoc)
{
$this->setModelDao(Loader::model($tagModel));
$this->tagAssocDao = Loader::model($tagAssoc);
}
示例11: __construct
public function __construct($financeModel, $commentAssoc = null)
{
$this->setModelDao(Loader::model($financeModel));
}
示例12: __construct
public function __construct($mediaModel, $mediaDataModel)
{
$this->mediaDataDao = Loader::model($mediaDataModel);
$this->setModelDao(Loader::model($mediaModel));
}
示例13: __construct
public function __construct($userModel, $userDataModel)
{
$this->userDataDao = Loader::model($userDataModel);
$this->setModelDao(Loader::model($userModel));
}
示例14: getDataDao
/**
* 获取文章内容表的dao实例
* @param int $aid 文章ID
* @return \herosphp\model\C_Model
*/
public function getDataDao($aid)
{
//获取文章数据表的节点
$node = $aid % self::DATA_TABLE_NODES;
$this->dataDao = Loader::model('ArticleData');
$tableMapping = $this->dataDao->getTableMapping();
//加载数据表配置
$dbConfigPath = 'db';
if (DB_CFG_PATH != false) {
$dbConfigPath = DB_CFG_PATH;
}
$tableConfig = Loader::config('table', $dbConfigPath);
$this->dataDao->setTable($tableConfig[$tableMapping[$node]]);
return $this->dataDao;
}