I have a trouble getting a code working with CI especially that I need to embed a complex condition on the join I want to extract and count information from all fields in A even though not satisfying the condition which will result in zero 0 as count
First case that works great for count
$this->db->distinct();
$this->db->select('A.id, count(B.id) AS C');
$this->db->from('A');
$this->db->join('B','B.id=A.id','left outer');
$this->db->group_by('A.id');
Now if I want to add a condition on a row from A that is a datetime, so that we extract all information from A AFTER a given date, and same thing, if a condition is not satisfying we return 0 :
$this->db->distinct();
$this->db->select('A.id, count(B.id) AS C');
$this->db->from('A');
$this->db->join('B','B.id=A.id','left outer');
$this->db->where('B.date >',$date);
$this->db->group_by('A.id');
This code is working but retruning only rows satisfying the condition and not all the other rows with 0 as count.
Can someone tell me what is wrong with the where clause ?
Thanks