'Greater than or equal' and 'less than or equal' CODEIGNITER
Change =<
to <=
.
I also tested your current query in phpmyadmin, because i could not believe that it does not throw an error. But mine does it. So your query should not work in phpmyadmin.
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=< ...' at line ...
Try to change the =<
to <=
like
->where('payment.paymentdate >=', $month_start)->where('payment.paymentdate <=', $month_end)
And better but not cumpolsury to join the table before the where condition.Now your query should be like
->select('COUNT(payment.keyid) AS rec_count')->select('product_key.client_name, product_key.contact_email, product_key.status, product_key.id, payment.paymentdate, (payment.id) as pid,payment.subscription_type')->from('product_key') ->join('payment', 'payment.keyid=product_key.id', 'left outer') ->where('payment.paymentdate >=', $month_start)->where('payment.paymentdate <=', $month_end)->where('status', 'purchased')->order_by('client_name', "asc")->group_by('product_key.id')->get()
from what i know, you can write them like this
$this->db->select('COUNT(payment.keyid) AS rec_count, product_key.client_name, product_key.contact_email, product_key.status, product_key.id, payment.paymentdate, (payment.id) as pid, payment.subscription_type', false);$this->db->where('payment.paymentdate >= "2013-08-01"');$this->db->where('payment.paymentdate <= "2013-08-31"');$this->db->where('status', 'purchased');$this->db->group_by('product_key.id');$this->db->order_by('client_name', 'asc');$this->db->join('payment', 'payment.keyid=product_key.id', 'LEFT OUTER')$this->db->get('product_key');