CodeIgniter Forums
Database query with multiple tables - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forum-22.html)
+--- Thread: Database query with multiple tables (/thread-1898.html)



Database query with multiple tables - El Forum - 07-03-2007

[eluser]cayasso[/eluser]
Is there a way to convert this query that are using two tables by using the Active Record Class

Code:
$query = $this->db->query('SELECT * FROM lkx_text, lkx_page WHERE lkx_page.pg_id = '.$pdid.' AND lkx_text.pg_id = lkx_page.pg_id');


for example this code

Code:
$query = $this->db->query('SELECT * FROM table1 WHERE table1_id = '.$var_id);

can be replaced with this

Code:
$this->db->where('table1_id', $var_id);
$query = $this->db->get('table1');

where you don't need to add the SELECT because it does it automatically. but how to do this with 2 tables.

I am newbie so have patient.

Thanks in advance for your help.


Database query with multiple tables - El Forum - 07-03-2007

[eluser]CodyPChristian[/eluser]
This may help you, not 100% sure.

http://ellislab.com/forums/viewthread/55617/