I'm trying to join 3 tables from 2 databases in codeigniter. This is my code :
<?php
public function get_order_products($orders_id) {
$this->db->from('database1.tbl_orders');
$this->db->join('database1.tbl_order_items','database1.tbl_order_items.orders_id=database1.tbl_orders.orders_id','left');
$this->db->join('database2.tbl_customers','database2.tbl_customers.customers_id=database1.tbl_orders.customer_id','left');
$this->db->where('database1.tbl_orders.orders_id',$orders_id);
$result=$this->db->get(); return $result->result(); }
?>
I have added the second database in my database.php file. Moreover i have added this statement in my model
public function Order_model1()
{
parent::__construct();
$this->grossery_db = $this->load->database('grossery_db',TRUE);
}
But still i am not able to get data from my second database. Can someone please tell me why that is happening?