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


PHP District::query方法代码示例

本文整理汇总了PHP中District::query方法的典型用法代码示例。如果您正苦于以下问题:PHP District::query方法的具体用法?PHP District::query怎么用?PHP District::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在District的用法示例。


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

示例1: districts_post

 public function districts_post($param)
 {
     $districts = array();
     if ($result = District::query()->where([['`id_city`', '=', $param['id']]])->order_by('`name`')->get()) {
         while ($row = $result->fetch_assoc()) {
             $d = array('id' => $row['id'], 'name' => $row['name']);
             array_push($districts, $d);
         }
         $result->free();
     }
     ob_end_clean();
     //var_dump($districts);
     echo json_encode($districts);
     exit;
 }
开发者ID:nakedwarrior,项目名称:NakedMVC,代码行数:15,代码来源:class-json_controller.php

示例2: edit_post

 public function edit_post($params)
 {
     $msg = array();
     $msg = $this->validate_info($params['fullname'], $params['phone'], $params['id_city'], $params['id_district'], $params['address'], $params['birth']);
     $cities = array();
     if ($result = City::query()->order_by('`name`')->get()) {
         while ($row = $result->fetch_assoc()) {
             $city = new City($row);
             array_push($cities, $city);
         }
         $result->free();
     }
     $districts = array();
     if ($params['id_city'] != '') {
         if ($result = District::query()->where([['`id_city`', '=', $params['id_city']]])->order_by('`name`')->get()) {
             while ($row = $result->fetch_assoc()) {
                 $district = new District($row);
                 array_push($districts, $district);
             }
             $result->free();
         }
     }
     if (sizeof($msg) > 0) {
         $this->render('views/user/edit.php', ['msg' => $msg, 'user' => new User($params), 'cities' => $cities, 'districts' => $districts]);
         return;
     } else {
         $result = User::query(['`id`'])->where([['`email`', '=', "'{$_SESSION['user']}'"]])->get();
         if ($row = $result->fetch_assoc()) {
             $id = $row['id'];
             $user = new User(['id' => $id, 'fullname' => $params['fullname'], 'phone' => $params['phone'], 'id_city' => $params['id_city'], 'id_district' => $params['id_district'], 'address' => $params['address'], 'birth' => date_format(date_create_from_format('d-m-Y', $params['birth']), 'Y/m/d')]);
             if ($user->update()) {
                 ob_end_clean();
                 header('Location:' . Path::go_to('user'));
                 exit;
             } else {
                 array_push($msg, 'Your account is not updated');
             }
             $this->render('views/user/edit.php', ['msg' => $msg, 'cities' => $cities, 'districts' => $districts, 'user' => $user]);
             return;
         }
     }
 }
开发者ID:nakedwarrior,项目名称:NakedMVC,代码行数:42,代码来源:class-user_controller.php


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