CodeIgniter query fails when JOINing tables from multiple databases
04:07 21 Sep 2020

When I join with two different database on production, I get this error:

Call to a member function num_rows() on boolean

On my localhost it is working fine.

My code:

$this->db->select('livedb.ADMIN_TEAM.id');
$this->db->from('livedb.ADMIN_TEAM'); 
          
$this->db->join("olap.SL_DEMO_ACTIVITY_COUNT", "(olap.SL_DEMO_ACTIVITY_COUNT.admin_id = livedb.ADMIN_TEAM.id) AND (olap.SL_DEMO_ACTIVITY_COUNT.assign_date='".$preData."')", "LEFT");
$this->db->join("olap.SL_DEMO_ACTIVITY_COUNT", "(olap.SL_DEMO_ACTIVITY_COUNT.admin_id = newforce_livedb.ADMIN_TEAM.id)", "LEFT");
          
$this->db->where('livedb.ADMIN_TEAM.team_status', '1');
$this->db->where('livedb.ADMIN_TEAM.team_type', 'sales');
$this->db->where('livedb.ADMIN_TEAM.id !=', '129');
$this->db->where('livedb.ADMIN_TEAM.sale_type', 'CRM');
$this->db->limit('1');
$this->db->order_by('livedb.ADMIN_TEAM.id', 'ASC');
$query = $this->db->get();
print_r($this->db->last_query());    

if ($query->num_rows() > 0) {
    return $query->result();
} else {
    return FALSE;
}
php codeigniter codeigniter-3 query-builder multiple-databases