当前位置: 首页>>代码示例>>PHP>>正文


PHP createModel函数代码示例

本文整理汇总了PHP中createModel函数的典型用法代码示例。如果您正苦于以下问题:PHP createModel函数的具体用法?PHP createModel怎么用?PHP createModel使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了createModel函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: order

 function order()
 {
     if (empty($_GET['id'])) {
         return "错误:父页面id为空";
     }
     $parent_id = intval($_GET['id']);
     $model = createModel('WikiTree');
     if (!empty($_POST['order'])) {
         $order = explode(',', $_POST['order']);
         $n = count($order);
         if ($n < 2) {
             return $this->message(501, '错误的请求');
         }
         foreach ($order as $k => $id) {
             $model->set($id, array('orderid' => $n - $k));
         }
         return $this->message(0, '排序操作成功');
     } else {
         $node = $model->get($parent_id);
         if ($node['order_by_time']) {
             return Swoole\JS::js_back("已启用自动时间排序,无法使用手工排序功能。");
         }
         $gets['pid'] = $parent_id;
         $gets['order'] = App\Content::$order;
         $childs = $model->gets($gets);
         $this->tpl->assign('childs', $childs);
         $this->tpl->display("wiki/order.html");
     }
 }
开发者ID:sunnycamel,项目名称:swoole.com,代码行数:29,代码来源:Wiki_admin.php

示例2: category

 function category()
 {
     if (empty($_GET['cid']) and empty($_GET['user'])) {
         error(409);
     }
     $_blog = createModel('UserLogs');
     $_cate = createModel('UserLogCat');
     $gets1 = array();
     if (isset($_GET['cid'])) {
         $cid = (int) $_GET['cid'];
         $cate = $_cate->get($cid)->get();
         $uid = $cate['uid'];
         $gets1['c_id'] = $cid;
     } else {
         $uid = (int) $_GET['user'];
         $cate = array();
     }
     $this->userinfo($uid);
     $gets1['uid'] = $uid;
     $gets1['dir'] = 0;
     $gets1['select'] = 'title,id,substring(content,1,1000) as des,addtime,reply_count,look_count';
     $gets1['page'] = empty($_GET['page']) ? 1 : (int) $_GET['page'];
     $gets1['pagesize'] = 10;
     $blogs = $_blog->gets($gets1, $pager);
     foreach ($blogs as &$m) {
         $m['addtime'] = date('n月j日 H:i', strtotime($m['addtime']));
         $m['des'] = mb_substr(strip_tags($m['des']), 0, 120);
     }
     $this->swoole->tpl->assign('cate', $cate);
     $this->swoole->tpl->assign('blogs', $blogs);
     $pager->span_open = array();
     $pager = array('total' => $pager->total, 'render' => $pager->render());
     $this->swoole->tpl->assign('pager', $pager);
     return $this->swoole->tpl->fetch('blog_category.html');
 }
开发者ID:netstao,项目名称:swoole.com,代码行数:35,代码来源:blog.php

示例3: getInfo

 function getInfo($uid)
 {
     $cache_key = 'user_info_' . $uid;
     $user = $this->swoole->cache->get($cache_key);
     if (empty($user)) {
         $forms = (require WEBPATH . '/dict/forms.php');
         $user = $this->get($uid)->get();
         if (!empty($user['sex'])) {
             $user['sex'] = $forms['sex'][$user['sex']];
         }
         if (!empty($user['education'])) {
             $user['education'] = $forms['education'][$user['education']];
         }
         $user['php_level'] = $forms['level'][$user['php_level']];
         $_skill = createModel('UserSkill')->getMap(array());
         if (!empty($user['skill'])) {
             $_s = explode(',', $user['skill']);
             foreach ($_s as $s) {
                 $skill[] = $_skill[$s];
             }
             $user['skill'] = $skill;
         }
         if (substr($user['avatar'], 4) != 'http') {
             $user['avatar'] = str_replace('/static/', $this->swoole->config['site']['static'], $user['avatar']);
         }
         $this->swoole->cache->set($cache_key, $user, $this->cache_life);
     }
     return $user;
 }
开发者ID:sunnycamel,项目名称:swoole.com,代码行数:29,代码来源:UserInfo.php

示例4: index

 function index()
 {
     //session();
     $data = createModel('UserInfo')->get(12)->get();
     $this->swoole->tpl->assign('data', $data);
     $html = $this->swoole->tpl->fetch('test.html');
     $time = $this->showTime();
     return $html . $time;
 }
开发者ID:superwmh,项目名称:swoole,代码行数:9,代码来源:test.php

示例5: sendmail

 static function sendmail($to, $from, $title, $msg)
 {
     $model = createModel('UserMail');
     $put['title'] = $title;
     $put['content'] = $msg;
     $put['fid'] = $from;
     $put['tid'] = $to;
     return $model->put($put);
 }
开发者ID:netstao,项目名称:swoole.com,代码行数:9,代码来源:Api.php

示例6: getByAid

 function getByAid($app, $aid, &$pager = null)
 {
     $gets['leftjoin'] = array(createModel('UserInfo')->table, createModel('UserInfo')->table . '.id=' . $this->table . '.uid');
     $gets['select'] = 'content,uid,uname,avatar,addtime';
     $gets['aid'] = $aid;
     $gets['app'] = $app;
     $gets['order'] = 'addtime desc';
     $gets['limit'] = 50;
     return $this->gets($gets);
 }
开发者ID:sunnycamel,项目名称:swoole.com,代码行数:10,代码来源:UserComment.php

示例7: getProjectInfo

 protected function getProjectInfo()
 {
     $this->project = createModel('WikiProject')->get($this->project_id);
     if (empty($this->project)) {
         echo "您访问的项目不存在";
         exit;
     }
     $this->swoole->tpl->assign("project_id", $this->project_id);
     $this->swoole->tpl->assign("project", $this->project);
 }
开发者ID:netstao,项目名称:swoole.com,代码行数:10,代码来源:wiki.php

示例8: newPage

 static function newPage($content)
 {
     $_cont = createModel('WikiContent');
     $in2['title'] = $content['title'];
     if (strlen($content['content']) > 0 and $content['content'][0] == '`') {
         $content['content'] = ' ' . $content['content'];
     }
     $in2['content'] = $content['content'];
     $in2['id'] = $content['id'];
     $_cont->put($in2);
 }
开发者ID:sunnycamel,项目名称:swoole.com,代码行数:11,代码来源:Content.php

示例9: smarty_function_model

function smarty_function_model($params, &$smarty)
{
    if (!isset($params['_from'])) {
        echo 'No model name!';
        return false;
    }
    if (!isset($params['_name'])) {
        echo 'No record variable name!';
        return false;
    }
    $smarty->_tpl_vars[$params['_name']] = createModel($params['_from'])->gets($model, $pager);
    if (isset($params['page'])) {
        $smarty->assign("pager", array('total' => $pager->total, 'render' => $pager->render()));
    }
}
开发者ID:superwmh,项目名称:swoole,代码行数:15,代码来源:function.model.php

示例10: detail

 function detail()
 {
     if (empty($_GET['id'])) {
         return "Access Deny";
     }
     $this->common();
     $aid = (int) $_GET['id'];
     //模板名称
     $tplname = strtolower($this->app) . '_detail.html';
     //获取详细内容
     $det = $this->_model->get($aid)->get();
     if (empty($det)) {
         $this->http->status(404);
         return "Page Not Found";
     }
     if (!empty($det['uptime']) and Swoole\Tool::httpExpire($det['uptime']) === false) {
         return "";
     }
     //阅读次数增加
     $this->_model->set($aid, array('click_num' => '`click_num`+1'));
     //关键词
     if (!empty($_GET['q'])) {
         $det['content'] = preg_replace("/({$_GET['q']})/i", "<font color=red>\\1</font>", $det['content']);
     }
     //获取小分类信息
     $cate = getCategory($det['cid']);
     $this->swoole->tpl->assign("cate", $cate);
     $ccate = getCategory($det['fid']);
     $this->swoole->tpl->assign("ccate", $ccate);
     $comments = createModel('UserComment')->getByAid($this->app, $det['id']);
     //是否使用特殊模板
     if ($ccate['tpl_detail']) {
         $tplname = $ccate['tpl_detail'];
     }
     if ($cate['tpl_detail']) {
         $tplname = $cate['tpl_detail'];
     }
     $this->swoole->tpl->assign('comments', $comments);
     $this->swoole->tpl->assign('det', $det);
     $this->swoole->tpl->display($tplname);
 }
开发者ID:sunnycamel,项目名称:swoole.com,代码行数:41,代码来源:Cms.php

示例11: onEditPDB

 function onEditPDB()
 {
     $req = $_REQUEST;
     //if($req['cmd'] == 'Cancel')
     if ($req['cmd'] == 'Go back') {
         pageGoto("editpdb_setup1.php");
         return;
     }
     // Otherwise, moving forward:
     $oldID = $req['modelID'];
     $oldModel = $_SESSION['models'][$oldID];
     $inpath = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS . '/' . $oldModel['pdb'];
     $newModel = createModel($oldID . "_edit");
     $newID = $newModel['id'];
     $outpath = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS . '/' . $newModel['pdb'];
     $s = "";
     if (is_array($req['removechain']) && count($req['removechain']) > 0) {
         removeChains($inpath, $outpath, $req['removechain']);
         $s .= "<p>You created {$newModel['pdb']} by removing chain(s) " . implode(', ', $req['removechain']) . " from {$oldModel['pdb']}.\n";
         mpLog("editpdb:Removed chains from a PDB file");
     } else {
         copy($inpath, $outpath);
     }
     $resolu = $req['resolution'] + 0;
     $oldRes = $oldModel['stats']['resolution'] + 0;
     if ($resolu && ($oldRes == 0 || $oldRes != $resolu)) {
         $remark2 = sprintf("REMARK   2                                                                      \nREMARK   2 RESOLUTION. %.2f ANGSTROMS.                                          \n", $resolu);
         replacePdbRemark($outpath, $remark2, 2);
         $s .= "<p>You manually set the resolution for {$newModel['pdb']}.\n";
         mpLog("editpdb:Changed/set resolution for a PDB file");
     }
     if ($req['removeHs']) {
         $newModel = createModel($oldID . "_trimmed");
         $newID = $newModel['id'];
         $outpath = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS . '/' . $newModel['pdb'];
         reduceTrim($inpath, $outpath);
         $s .= "<p>You created {$newModel['pdb']} by removing hydrogens from {$oldModel['pdb']}.\n";
         mpLog("editpdb:Removed hydrogens from a PDB file");
     }
     $newModel['stats'] = pdbstat($outpath);
     $newModel['history'] = "Edited {$oldModel['pdb']}";
     $newModel['isUserSupplied'] = $oldModel['isUserSupplied'];
     $_SESSION['models'][$newID] = $newModel;
     $_SESSION['lastUsedModelID'] = $newID;
     // this is now the current model
     $details = describePdbStats($newModel['stats'], true);
     $s .= "<ul>\n";
     foreach ($details as $detail) {
         $s .= "<li>{$detail}</li>\n";
     }
     $s .= "</ul>\n";
     $entrynum = addLabbookEntry("Created PDB file {$newModel['pdb']}", $s, "{$oldID}|{$newID}", "auto", "scissors.png");
     pageGoto("generic_done.php", array('labbookEntry' => $entrynum));
 }
开发者ID:smlewis,项目名称:MolProbity,代码行数:54,代码来源:editpdb_setup2.php

示例12: cms_list

function cms_list(&$params, &$smarty)
{
    if (empty($params['cid'])) {
        exit('分类不能为空');
    }
    $cid = (int) $params['cid'];
    if (empty($params['name'])) {
        $params['name'] = 'list' . $cid;
    }
    $cate = getCategory($cid);
    $model = createModel($cate['app']);
    if ($cate['fid'] == 0) {
        $gets['fid'] = $cid;
    } else {
        $gets['cid'] = $cid;
    }
    if (empty($params['select'])) {
        $params['select'] = 'id,title,addtime';
    }
    if (empty($params['num'])) {
        $params['num'] = 10;
    }
    //查询的条数
    $gets['limit'] = (int) $params['num'];
    //查询的字段
    $gets['select'] = $params['select'];
    if (!empty($params['order'])) {
        $gets['order'] = $params['order'];
    }
    if (!empty($params['dig'])) {
        $gets['tagid'] = (int) $params['dig'];
    }
    if (!empty($params['titlelen'])) {
        $gets['select'] = str_replace('title', "substring( title, 1, {$gets['titlelen']} ) AS title,title as title_full", $gets['select']);
    }
    $smarty->_tpl_vars[$params['name']] = $model->gets($gets);
}
开发者ID:netstao,项目名称:swoole.com,代码行数:37,代码来源:func.php

示例13: createView

function createView($name)
{
    $view = 'Hello World!';
    mkdir(VIEWS_DIR . $name);
    $handle = fopen(VIEWS_DIR . $name . DIRECTORY_SEPARATOR . 'v_index.php', 'w+');
    fwrite($handle, $view);
    fclose($handle);
}
if ($argc > 1) {
    //Define controller, model, and view directory
    define('CONTROLLERS_DIR', realpath(__DIR__ . '/app/controllers') . DIRECTORY_SEPARATOR);
    define('MODELS_DIR', realpath(__DIR__ . '/app/models') . DIRECTORY_SEPARATOR);
    define('VIEWS_DIR', realpath(__DIR__ . '/app/views') . DIRECTORY_SEPARATOR);
    //User command
    if ($argv[1] == 'controller') {
        createController($argv[2]);
        createView($argv[2]);
        fwrite(STDOUT, 'Controller c_' . $argv[2] . ' and View ' . $argv[2] . '/v_index.php created successfully');
    } else {
        if ($argv[1] == 'model') {
            createModel($argv[2], $argv[3], $argv[4]);
            fwrite(STDOUT, 'Model m_' . $argv[2] . ' created successfully');
        } else {
            fwrite(STDOUT, "Wrong command\n");
            fwrite(STDOUT, "Here the list of command:\n" . "1. controller <name>\n" . "2. model <table-name> <field-list> <primary-key>\n");
        }
    }
} else {
    //Write if user didn't specify arguments
    fwrite(STDOUT, "Please specify the arguments. You can use:\n" . "1. controller <name>\n" . "2. model <table-name> <field-list> <primary-key>\n");
}
开发者ID:semplon,项目名称:aksarajawagenerator,代码行数:31,代码来源:aries.php

示例14: admin_attachment

 function admin_attachment()
 {
     $this->_check_cms();
     import_func('file');
     import_func('js');
     $model = createModel('Attachment');
     $entity = createModel($this->app);
     if (empty($_GET['aid'])) {
         $res = $entity->getStatus();
         $id = $res['Auto_increment'];
     } else {
         $id = (int) $_GET['aid'];
     }
     if (isset($_GET['del'])) {
         $model->del((int) $_GET['del']);
     }
     if (isset($_FILES['media'])) {
         if (empty($_POST['title'])) {
             $_POST['title'] = $_FILES['media']['name'];
         }
         $_POST['url'] = file_upload('media');
         if (!empty($_POST['url'])) {
             $_POST['filetype'] = file_gettype($_FILES['media']['type']);
             $_POST['filesize'] = $_FILES['media']['size'];
             $_POST['user_id'] = $this->uid;
             $_POST['app'] = $this->app;
             $model->put($_POST);
         }
     }
     $list = $model->gets(array('aid' => $id, 'app' => $this->app));
     include "templates/admin_attachment.html";
 }
开发者ID:netstao,项目名称:swoole.com,代码行数:32,代码来源:admin.php

示例15: elseif

if ($reduce_blength == 'ecloud') {
    $newModel['history'] = "Derived from {$model['pdb']} by Reduce -build";
} elseif ($reduce_blength == 'nuclear') {
    $newModel['history'] = "Derived from {$model['pdb']} by Reduce -build -nuclear";
}
$newModel['isUserSupplied'] = $model['isUserSupplied'];
$newModel['isReduced'] = true;
$newModel['isBuilt'] = true;
$_SESSION['models'][$newModel['id']] = $newModel;
$_SESSION['bgjob']['modelID'] = $newModel['id'];
$_SESSION['lastUsedModelID'] = $newModel['id'];
// this is now the current model
if ($did_flip && $_SESSION['bgjob']['nqh_regularize']) {
    setProgress($tasks, 'regularize');
    $flipInpath = $outpath;
    $minModel = createModel($modelID . "FH_reg");
    $outname2 = $minModel['pdb'];
    $outpath2 = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS;
    $outpath2 .= '/' . $outname2;
    $temp = $_SESSION['dataDir'] . '/tmp';
    if (file_exists($flipInpath)) {
        regularizeNQH($flipInpath, $outpath2, $temp);
    }
    unset($_SESSION['models'][$_SESSION['lastUsedModelID']]);
    if (!file_exists($outpath2)) {
        # We are deleting the reduced file because we'd rather not have users
        # play with the unregularized, nqh-flipped pdb.
        unlink($flipInpath);
        $_SESSION['lastUsedModelID'] = $prereduceid;
        unset($_SESSION['bgjob']['processID']);
        $_SESSION['bgjob']['endTime'] = time();
开发者ID:smlewis,项目名称:MolProbity,代码行数:31,代码来源:reduce-build.php


注:本文中的createModel函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。