I am trying to query data from two tables namely "tbl_tmpdtr"
and "tbl_employee"
using date range to compare in the tbl_tmpdtr
field namely in_out datetime().
i have two input type="date" in my view as i pass it on my controller { $this->input->post('from_date');
$this->input->post('to_date') }
to be used in my model check out the code below.
public function view_emp_dtr($a, $b)
{
$q = $this->db->query('SELECT tbl_tmpdtr.id, tbl_tmpdtr.userid, date(tbl_tmpdtr.in_out) as in_out, tbl_tmpdtr.status, tbl_employee.emp_id, tbl_employee.emp_lname, tbl_employee.emp_mname, tbl_employee.emp_fname, tbl_employee.emp_gender, tbl_employee.civil_status, tbl_employee.dob, tbl_employee.street, tbl_employee.barangay, tbl_employee.city, tbl_employee.province, tbl_employee.emp_contact, tbl_employee.spouse_lname, tbl_employee.spouse_mname, tbl_employee.spouse_fname, tbl_employee.spouse_gender, tbl_employee.relationship, tbl_employee.address, tbl_employee.spouse_num, tbl_employee.jobtitle_id, tbl_employee.store_id, tbl_employee.username, tbl_employee.password, tbl_employee.hiredate, tbl_employee.emp_status, tbl_employee.Image FROM tbl_tmpdtr INNER JOIN tbl_employee ON tbl_tmpdtr.userid = tbl_employee.emp_id WHERE in_out<='$a' AND in_out>='$b' GROUP BY tbl_tmpdtr.userid');
if($q->num_rows() > 0)
{
foreach($q->result() as $row)
{
$data[]= $row;
}
return $data;
}
}
my problem: the variable $a and $b are considered as columns;