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


PHP Model::select方法代碼示例

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


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

示例1: getList

 public function getList($wheres = array())
 {
     //查詢條件為數據狀態大於 -1  的數據
     if (!empty($wheres)) {
         $wheres['status'] = array('gt', -1);
     } else {
         $wheres['status'] = array('gt', -1);
     }
     //獲取分頁的工具條
     $totalRows = $this->where($wheres)->count();
     //準備數數據狀態大於-1的總條數
     $listRows = 2;
     //確定每一頁顯示的數據條數
     //實例化分頁工具條的對像
     $page = new Page($totalRows, $listRows);
     //>>判斷是否要修改主題
     if ($totalRows > $listRows) {
         $page->setConfig('theme', '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%');
     }
     //存儲分頁的條件
     $pageHtml = $page->show();
     //>>每一頁的數據刪除完之後顯示這頁數據的上一頁
     //查詢出每一頁需要顯示的數據
     $this->limit($page->firstRow, $page->listRows)->where($wheres);
     $rows = parent::select();
     return array('rows' => $rows, 'pageHtml' => $pageHtml);
 }
開發者ID:githublming,項目名稱:1009php,代碼行數:27,代碼來源:BaseModel.class.php

示例2: index

 public function index()
 {
     $model = new Model('Category');
     $list = $model->select();
     $this->assign('list', $list);
     $this->display();
 }
開發者ID:xialeistudio,項目名稱:thinkphp-inaction,代碼行數:7,代碼來源:CategoryController.class.php

示例3: db

 public function db()
 {
     $m = new Model('Post');
     $list = $m->select();
     dump($list);
     echo $m->getLastSql();
 }
開發者ID:xialeistudio,項目名稱:thinkphp-inaction,代碼行數:7,代碼來源:IndexController.class.php

示例4: getActionList

 function getActionList()
 {
     header('Access-Control-Allow-Origin:*');
     //跨域
     header("Content-type: text/html; charset=utf-8");
     $param = json_decode(file_get_contents('php://input'), true);
     $token = $param['xtoken'];
     //init_verify_token($token);
     $t_action = C('T_ACTION');
     $model = new Model($t_action);
     $result = $model->select();
     $data["errno"] = 0;
     $data["action_list"] = $result;
     echo json_encode($data);
 }
開發者ID:kaka2007,項目名稱:xplan,代碼行數:15,代碼來源:CoachController.class.php

示例5: getUsers

 /**
  * 獲取用戶
  * @return mixed
  */
 public function getUsers()
 {
     $User = new Model('user');
     return $User->select();
 }
開發者ID:ljhchshm,項目名稱:Recruitment-,代碼行數:9,代碼來源:UserModel.class.php

示例6: testModel

 public function testModel()
 {
     $config = array('db_type' => 'mysql', 'db_user' => 'root', 'db_pwd' => 'root123', 'db_host' => 'localhost', 'db_port' => '3306', 'db_name' => 'test');
     $modle = new Model('user', '', $config);
     var_dump($modle->select());
 }
開發者ID:kdf5000,項目名稱:tpdb,代碼行數:6,代碼來源:ModelTest.php

示例7: select

 /**
  * 使用相套sql語句,代替視圖
  * */
 public function select($options = array())
 {
     if (!empty($this->viewTableName)) {
         $orgTableName = $options["table"];
         $options["table"] = $this->viewTableName;
     }
     //
     $res = parent::select($options);
     $options["table"] = $orgTableName;
     return $res;
 }
開發者ID:ppker,項目名稱:minephp,代碼行數:14,代碼來源:DxExtCommonModel.class.php

示例8: getCategories

 public function getCategories()
 {
     $Category = new Model('category');
     return $Category->select();
 }
開發者ID:ljhchshm,項目名稱:Recruitment-,代碼行數:5,代碼來源:CategoryModel.class.php

示例9: select

 /**
  * 重寫select方法 以支持associate和sqlOptions
  * 
  * 如果傳入了['hy'=>true]則模型SQL基礎配置生效!
  * 如果調用了associate連貫操作,則會執行框架的連表查詢
  * 
  * @param array $options 表達式參數
  * @return array
  */
 public function select($options = array())
 {
     if (!($arr = $this->isCallHyFunc($options))) {
         return parent::select($options);
     }
     list($hy, $associate) = $arr;
     if ($associate) {
         $associate = array_merge($hy ? $this->sqlOptions['associate'] : array(), $this->_associate);
     }
     // 收集table
     if ($associate) {
         $this->table(array($this->getTableName() => self::HYP));
     }
     // 收集limit
     if ($hy && !$this->options['limit']) {
         $this->limit($this->pageOptions['limit']);
     }
     // 收集order
     if ($order = $this->options['order'] ?: ($hy ? $this->pageOptions['order'] : null)) {
         // 排序字段自動加表別名以避免衝突
         if ($associate && is_string($order)) {
             $order = $this->fieldPre($order, self::HYP);
         }
         $this->options['order'] = $order;
     }
     // 收集field
     if ($associate && ($field = $this->options['field'] ?: ($hy ? $this->sqlOptions['field'] : array()))) {
         // 防止多表中字段衝突
         if (is_string($field)) {
             $field = $this->fieldPre($field, self::HYP);
             if (is_string($field)) {
                 $field = array($field);
             }
         }
         if (is_array($field)) {
             foreach ($field as $k => $v) {
                 if (is_numeric($k)) {
                     $field[$k] = $this->fieldPre($field[$k], self::HYP);
                 }
             }
         }
     } else {
         $field = $this->getAllFields($field, $associate ? self::HYP : '');
     }
     // 收集 where - sqlOptions
     if ($hy) {
         // 拷貝副本,不影響下次使用sqlOptions['where']
         $this->sqlOptions['_where'] = $this->sqlOptions['where'];
         // 收集where - search
         if ($hy && method_exists($this, 'searchMap')) {
             $this->searchMap();
         }
         if ($this->options['where']['_string']) {
             $this->addMap($this->options['where']['_string']);
             unset($this->options['where']['_string']);
         }
         // 整合到TP
         $this->where($this->sqlOptions['_where']);
     }
     // where條件中的字段避免衝突
     if ($associate && $this->options['where']) {
         $arr = array();
         foreach ($this->options['where'] as $k => $v) {
             if (0 === strpos($k, '_')) {
                 continue;
             }
             $arr[$this->fieldPre($k, self::HYP)] = $v;
             unset($this->options['where'][$k]);
         }
         if ($arr) {
             $this->where($arr);
         }
     }
     // 連表處理
     if (is_array($associate) && $associate) {
         // 當前表默認別名 HYP常量
         $join = array();
         foreach ($associate as $v) {
             $asc = explode('|', $v);
             // 0=>關聯表名(支持別名),1=>當前表外鍵,2=>關聯表主鍵,3=>要從關聯表取出的字段(多個以“,”分隔),4=>限製條件,5=>join類型(默認inner)
             preg_match('/([\\w\\.\\-\\(\\)]+)\\s*(AS)*\\s*([\\w\\-]*)/i', $asc[0], $m);
             $asc[0] = $m[3] ?: $m[1];
             if ($asc[4]) {
                 $pre = $asc[0] . '.';
                 $asc[4] = preg_replace_callback('/`([\\w\\-]+)`/', function ($m1) use($pre) {
                     if ($m1[1]) {
                         return $pre . $m1[1];
                     }
                 }, $asc[4]);
             }
             $asc[5] = $asc[5] ? strtoupper($asc[5]) : 'INNER';
//.........這裏部分代碼省略.........
開發者ID:homyit,項目名稱:HyFrame,代碼行數:101,代碼來源:HyFrameModel.class.php

示例10: addManyDayCourse

 function addManyDayCourse()
 {
     header('Access-Control-Allow-Origin:*');
     //跨域
     header("Content-type: text/html; charset=utf-8");
     $param = json_decode(file_get_contents('php://input'), true);
     /*   $str = '{
         "xtoken":"35dsakfsdjfcvjdsajfkdsf234",
         "coachid":45,
         "uid":999,
         "pid":41,
         "course_list":[
         {
             "course_time":32435435,
             "action_list":[
             {
                 "actionid":177,
                 "group":3,
                 "count":20,
                 "order":1,
                 "type":1,
                 "duration":34
             },
             {   
                 "actionid":188,
                 "group":3,
                 "count":20,
                 "order":1,
                 "type":2,
                 "duration":54
             }]
         },
         {
             "course_time":32438935,
             "action_list":[
             {
                 "actionid":199,
                 "group":3,
                 "count":20,
                 "order":1,
                 "type":1,
                 "duration":34
             },
             {   
                 "actionid":166,
                 "group":3,
                 "count":20,
                 "order":1,
                 "type":2,
                 "duration":54
             }]
         }]
     }';*/
     // $param = json_decode($str,true);
     $token = $param['xtoken'];
     init_verify_token($token);
     $uid = $param['uid'];
     $pid = $param['pid'];
     $coachid = $param['coachid'];
     if (!isset($uid) || !isset($pid) || !isset($coachid)) {
         err_ret(-205, 'lack of param', '缺少參數');
     }
     $course_list = $param['course_list'];
     //找到開始時間和結束時間
     $begin_time = $course_list[0]['course_time'];
     $end_time = $course_list[0]['course_time'];
     for ($i = 0; $i < count($course_list); $i++) {
         if ($course_list[$i]['course_time'] <= $begin_time) {
             $begin_time = $course_list[$i]['course_time'];
         }
         if ($course_list[$i]['course_time'] >= $end_time) {
             $end_time = $course_list[$i]['course_time'];
         }
     }
     //課程id
     $model_course_record = new Model('course_record');
     $cur_courseid = $model_course_record->max('courseid') + 1;
     //獲取 pay_time
     $model_my_plan = new Model('my_plan');
     $condition['uid'] = $uid;
     $condition['pid'] = $pid;
     $condition['coachid'] = $coachid;
     $condition['courseid'] = 0;
     $result_pay_time = $model_my_plan->select();
     $pay_time = $result_pay_time[0]['pay_time'];
     $model_my_plan->where($condition)->delete();
     //刪除記錄為courseid=0的
     for ($i = 0; $i < count($course_list); $i++) {
         //添加課程記錄
         $action_list = $course_list[$i]['action_list'];
         for ($j = 0; $j < count($action_list); $j++) {
             $action_list[$j]['courseid'] = $cur_courseid;
             $model_course_record->add($action_list[$j]);
         }
         //把相應的課程記錄添加到my_plan
         unset($data_my_plan);
         $data_my_plan['uid'] = $uid;
         $data_my_plan['pid'] = $pid;
         $data_my_plan['coachid'] = $coachid;
         $data_my_plan['courseid'] = $cur_courseid;
//.........這裏部分代碼省略.........
開發者ID:kaka2007,項目名稱:xplan,代碼行數:101,代碼來源:CourseController.class.php

示例11: getSlides

 public function getSlides()
 {
     $Slide = new Model('slide');
     return $Slide->select();
 }
開發者ID:ljhchshm,項目名稱:Recruitment-,代碼行數:5,代碼來源:SlideModel.class.php


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