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


PHP Room::find_by_id方法代码示例

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


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

示例1: redirect_to

<?php

require_once "../../includes/initialize.php";
if (!$session->is_logged_in()) {
    redirect_to("login.php");
}
if (!isset($_GET['id'])) {
    redirect_to("login.php");
}
$room = Room::find_by_id($_GET['id']);
if (!$room) {
    redirect_to("login.php");
}
if ($session->user_id != $room->hotel_id) {
    redirect_to("login.php");
}
$count_photo = RoomPhoto::find_photo_by_room($room->id);
$max_file_size = 1048567;
$message1 = "";
$message2 = "";
$message3 = "";
$message4 = "";
if (isset($_POST['submit'])) {
    if (empty($count_photo)) {
        $room_photo = new RoomPhoto();
        $room_photo->room_id = $room->id;
        $room_photo->attach_file($_FILES['upload_file']);
        if ($room_photo->save()) {
            redirect_to("hotel_page.php?id={$room->hotel_id}");
        } else {
            $message1 = join("<br>", $room_photo->errors);
开发者ID:kochevRisto,项目名称:project,代码行数:31,代码来源:room_photo.php

示例2: trim

    $adults = $_POST['adults'];
    $childs = $_POST['childs'];
    $price = trim($_POST['price']);
    $new_room = new Room();
    $new_room->hotel_id = $hotel->id;
    $new_room->make($room_name, $adults, $childs, $price);
    if (empty($new_room->errors) && $new_room->create()) {
        $session->message('Room created');
        redirect_to("add_room.php?id={$hotel->id}&room={$new_room->id}");
    } else {
        $message = join("<br>", $new_room->errors);
    }
}
$room = '';
if (isset($_GET['room']) && !empty($_GET['room'])) {
    $room = Room::find_by_id($_GET['room']);
}
if (isset($_POST['submit1'])) {
    if (!empty($room)) {
        $room_photo = new RoomPhoto();
        $room_photo->room_id = $room->id;
        $room_photo->attach_file($_FILES['upload_file']);
        if ($room_photo->save()) {
            redirect_to("page.php?id={$hotel->id}");
        } else {
            $message = join("<br>", $room_photo->errors);
        }
    } else {
        $session->message("First you have to create a room");
        redirect_to("add_room.php?id={$hotel->id}");
    }
开发者ID:kochevRisto,项目名称:project,代码行数:31,代码来源:add_room.php


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