How can CodeIgniter's query builder methods be used to implement a CROSS JOIN?
I tried this:
$this->db->join('tableTwo as b', '', 'CROSS');
$result = $this->db
->get('tableOne as a')
->result();
Solution for cross join in codeigniter:
$this->db->join('tableTwo as b','true');
$result = $this->db->get('tableOne as a')->result();
$this->db->join('tableTwo as b','1=1'); //true relation
$result = $this->db->get('tableOne as a')->result();
$result = $this->db->get(['tableOne as a','tableTwo as b'])->result();
$result = $this->db->from(['tableOne as a','tableTwo as b'])
get()->result(); //by this method you can add as many table you want to join
or by passing one table in from and other in get method
$result = $this->db->from('tableOne as a')
get('tableTwo as b')->result();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With