php - Codeigniter active record find available dates for rental items -
i creating site users can rent items. have 2 tables. rentals , inventory. inventory table has details product , rentals table has inventory id , start date / end date booking purposes. if client books item need check if dates available using active record in codeigniter. ideas on how accomplish this...
here rentals table...
id | customerid | productsid | periodstart (datetime) | periodend (datetime) | status
my user chooses start date datepicker in datetime format (y-m-d).
the website adds amount of days start date formulate end date. end customers desired date range this:
$starttime = $_post['date']; $endtime = strtotime('+'.$periodlength.'day', $starttime);
how can find out if date range available in rentals table i've described above. i'm not familiar joins, sense may necessary here.
i have tried few things none of has worked. ideas appreciated.
you may utilize
$this->db->where('start_date >=', $starttime ); $this->db->where('end_date <=', $endtime); $count= $this->db->count_all_results('rentals'); if($count > something) //your business logic here homecoming true; else homecoming false
no joins needed if right can add together other clauses id or whatever
php mysql codeigniter activerecord
No comments:
Post a Comment