本文整理汇总了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;
}
示例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;
}
}
}