當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ContentModel::where方法代碼示例

本文整理匯總了PHP中ContentModel::where方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContentModel::where方法的具體用法?PHP ContentModel::where怎麽用?PHP ContentModel::where使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ContentModel的用法示例。


在下文中一共展示了ContentModel::where方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: edit

 public function edit()
 {
     $content = new ContentModel();
     $id = $_GET['id'];
     if ($id != '') {
         $data = $content->where("id={$id}")->select();
         if (!empty($data)) {
             $this->assign('data', $data);
         } else {
             echo "data is NULL!";
         }
     }
     $this->assign('title', 'edit page');
     $this->display();
 }
開發者ID:highestgoodlikewater,項目名稱:class-website,代碼行數:15,代碼來源:IndexAction.class.php

示例2: create

 public function create()
 {
     unset($_GET['_URL_']);
     if (isset($_GET['start'])) {
         //每輪更新數
         $pagesize = (int) $this->_get("pagesize");
         $_GET['pagesize'] = $pagesize = $pagesize > 1 ? $pagesize : 100;
         //模型
         $_GET['modelid'] = $modelid = (int) $this->_get("modelid");
         //第幾輪更新
         $page = $_GET['start'] = (int) $this->_get("start");
         //總共幾輪
         $pages = (int) $this->_get("pages");
         //信息總數
         $total = (int) $this->_get("total");
         $model = F("Model");
         //如果是重建所有模型
         if ($modelid) {
             $table_name = ucwords($model[$modelid]['tablename']);
             if (!$table_name) {
                 $this->error("該模型不存在!");
             }
             $ContentDb = new ContentModel($table_name);
             if (!in_array($modelid, $this->config['modelid'])) {
                 $this->error("該模型無需重建!");
             }
             //取得總數
             if (!isset($_GET['total'])) {
                 $count = $ContentDb->where(array("status" => 99))->count();
                 //信息總數
                 $total = $_GET['total'] = $count;
                 //總共幾輪
                 $pages = $_GET['pages'] = ceil($_GET['total'] / $pagesize);
                 //初始第一輪更新
                 $page = $_GET['start'] = 1;
             }
             $page = max(intval($page), 1);
             $offset = $pagesize * ($page - 1);
             $data = $ContentDb->relation(true)->where(array("status" => 99))->order(array("id" => "ASC"))->limit($offset . "," . $pagesize)->select();
             if (!$data) {
                 $data = array();
             }
             //數據處理
             foreach ($data as $r) {
                 //組合數據
                 $inputinfo = array();
                 $inputinfo['system'] = $r;
                 $inputinfo['model'] = $r[$table_name . "_data"];
                 $id = $r['id'];
                 $this->db->search_api($id, $inputinfo, $modelid);
             }
             if ($pages == $page || $page > $pages) {
                 $this->success("更新完成! ...", U("Search/create"));
                 exit;
             }
             if ($pages > $page) {
                 $page++;
                 $_GET['start'] = $page;
                 $creatednum = $offset + count($data);
                 $percent = round($creatednum / $total, 2) * 100;
                 $message = "有 <font color=\"red\">{$total}</font> 條信息 - 已完成 <font color=\"red\">{$creatednum}</font> 條(<font color=\"red\">{$percent}%</font>)";
                 $forward = U("Search/create", $_GET);
                 $this->assign("waitSecond", 200);
                 $this->success($message, $forward);
                 exit;
             }
         } else {
             //當沒有選擇模型更新時,進行全部可用模型數據更新
             $modelArr = $this->config['modelid'];
             $autoid = $this->_get("autoid");
             $autoid = $_GET['autoid'] ? intval($_GET['autoid']) : 0;
             if (!isset($modelArr[$autoid])) {
                 $this->success("更新完成! ...", U("Search/create"));
                 exit;
             }
             $modelid = $modelArr[$autoid];
             $table_name = ucwords($model[$modelid]['tablename']);
             if (!$table_name) {
                 $this->error("該模型不存在!");
             }
             $ContentDb = new ContentModel($table_name);
             //取得總數
             if (!isset($_GET['total'])) {
                 $count = $ContentDb->where(array("status" => 99))->count();
                 //信息總數
                 $total = $_GET['total'] = $count;
                 //總共幾輪
                 $pages = $_GET['pages'] = ceil($_GET['total'] / $pagesize);
                 //初始第一輪更新
                 $page = $_GET['start'] = 1;
             }
             $page = max(intval($page), 1);
             $offset = $pagesize * ($page - 1);
             $data = $ContentDb->relation(true)->where(array("status" => 99))->order(array("id" => "ASC"))->limit($offset . "," . $pagesize)->select();
             if (!$data) {
                 $data = array();
             }
             //數據處理
             foreach ($data as $r) {
                 //組合數據
//.........這裏部分代碼省略.........
開發者ID:BGCX262,項目名稱:ztoa-svn-to-git,代碼行數:101,代碼來源:SearchAction.class.php


注:本文中的ContentModel::where方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。