【问题标题】:Checking room availability using codeigniter query使用 codeigniter 查询检查房间可用性
【发布时间】:2019-07-16 09:27:00
【问题描述】:

我是 Codeigniter 的新手。 现在我正在开发一个酒店房间预订系统。现在我在预订时检查房间可用性时遇到了一些问题。

我的房间可用性查询

$cindt = $this->input->post('myCheckInDate');
$coutdt = $this->input->post('myCheckOutDate');
$roomid = $this->input->post('room');
$this->db->select('*');
$this->db->from('booking');
$this->db->where("b_room", $roomid);
       $this->db->where('b_cin <= ',$cindt);
       $this->db->where('b_cout <= ',$cindt);
       $this->db->where('b_cout >= ',$coutdt);  
       $this->db->where('b_cin >= ',$coutdt);       
            $query = $this->db->get();
            $nn=$query->result_array(); 
                        //print_r($nn); exit();

    if($nn){
        $this->session->set_flashdata('yes', 'Rooms is not Available');
                    redirect($_SERVER['HTTP_REFERER']);
                }

【问题讨论】:

  • 你没有得到想要的结果是什么问题?
  • @MasivuyeCokile 是的,没有得到想要的结果。
  • 房间总数在哪里?
  • @Nikhil 你能在选择语句之前向我们展示你所有的 POST 值吗?我认为您的日期格式与 DB Column 格式不匹配

标签: php sql codeigniter


【解决方案1】:
$cindt = $this->input->post('myCheckInDate');
$coutdt = $this->input->post('myCheckOutDate');
$roomid = $this->input->post('room');

    $this->db->select('*');
    $this->db->where('b_cin >=', $cindt);
    $this->db->where('b_cout <=', $coutdt);
    $this->db->where('b_room', $roomid);
    $this->db->from('booking');
    $nn = $this->db->get()->result();

  if($nn > 0){
        $this->session->set_flashdata('yes', 'Rooms is not Available');
                    redirect($_SERVER['HTTP_REFERER']);
                }

【讨论】:

    猜你喜欢
    • 2016-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-23
    • 2012-06-03
    • 1970-01-01
    • 1970-01-01
    • 2014-07-14
    相关资源
    最近更新 更多