DB relations in Codeigniter |
Hi guys, I'm getting desperate trying to figure out how can I access data from DB by using relations. I have successfully related two tables by setting foreign key and now I am little bit confused.
Let's say I have two tables -> Cars(id, size, color) and Drivers(id, car_id, name). IDs are primary keys, car_id is foreign key. Now, I'd like to know what color or size is George's car. Could someone tell me what is the easiest way to echo it by Codeigniter? (06-13-2015, 03:29 PM)tomop Wrote: Hi guys, I'm getting desperate trying to figure out how can I access data from DB by using relations. I have successfully related two tables by setting foreign key and now I am little bit confused. You can join two tables like following: PHP Code: $driver_name = "George";
Actives recode has best example of db relations that you can integrate into your code. check out the documentation for more information.
here is an example $this->db->select("*")->from("table")->join("other", "table.id = ogher.fk");
NexoPOS 2.6.2 available on CodeCanyon.
|
Welcome Guest, Not a member yet? Register Sign In |