John Davidson

php - Multiple where condition in codeigniter not working


Hi I am trying to run a result on calendar where if booking is done fetch result including Accomodation ID and Property type. The first condition on where works not the second and third, don't know what am I doing wrong. Below is my code, from my model.

$this->db->where("FromDt between '$fromdate' AND '$toDate' OR toDate between '$fromdate' AND '$toDate' OR '$fromdate' between FromDt AND toDate OR '$toDate' between FromDt AND toDate");
$this->db->where('AccomId =', 5);
$this->db->where('propertytype =', 1);

The first code which is checking the dates is working not the next two I have even tried

$this->db->where('AccomId', 5);
$this->db->where('propertytype', 1);

Expecting your valuable support, Thank you in Advance

My Answer:
db->select('accomodation_id, property_type');
$this->db->where('booking', 'done');
$this->db->where('accomodation_id', $accomodation_id);
$this->db->where('property_type', $property_type);
$query = $this->db->get();
return $query->result();

Rate this post

4 of 5 based on 4232 votes


© 2024 - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us