Welcome Guest, Not a member yet? Register   Sign In
my_model, queries and joins
#6

[eluser]C.T.[/eluser]
Problem Table
=====================
posts:
post_id
post_title

cats:
cat_id
cat_title

post_cat:
*id
post_id
cat_id

Code:
$this->db->select('post_cat.id AS id');
$this->db->select('cats.cat_title AS category');
$this->db->select('posts.post_title AS title');
$this->db->join('posts', 'posts.id = post_cat.post_id');
$this->db->join('cats', 'cats.id = post_cat.cat_id');

$query = $this->db->get('post_cat');

Try this?
maybe you can have a look at http://ellislab.com/codeigniter/user-gui...ecord.html


Messages In This Thread
my_model, queries and joins - by El Forum - 04-16-2012, 12:56 PM
my_model, queries and joins - by El Forum - 04-16-2012, 02:41 PM
my_model, queries and joins - by El Forum - 04-16-2012, 02:55 PM
my_model, queries and joins - by El Forum - 04-16-2012, 02:57 PM
my_model, queries and joins - by El Forum - 04-16-2012, 03:14 PM
my_model, queries and joins - by El Forum - 04-16-2012, 03:24 PM
my_model, queries and joins - by El Forum - 04-16-2012, 03:29 PM
my_model, queries and joins - by El Forum - 04-16-2012, 03:39 PM
my_model, queries and joins - by El Forum - 04-16-2012, 04:30 PM
my_model, queries and joins - by El Forum - 04-16-2012, 04:33 PM
my_model, queries and joins - by El Forum - 04-16-2012, 04:45 PM
my_model, queries and joins - by El Forum - 04-16-2012, 06:33 PM
my_model, queries and joins - by El Forum - 04-16-2012, 07:02 PM



Theme © iAndrew 2016 - Forum software by © MyBB