I need help in CodeIgniter , get data from database

I have 3 table : users , posts , category

category : id , name

1 linux
2 Mac

users : id , name , email , image

1  Jak    t@t.com    afs
2  Stif   t2@t.com    122afs

posts : id , idc , idu , title , content

If I use getall function

function getall(){
   $this->db->order_by("id", "desc"); 
   $query = $this->db->get('posts');
   return $query->result();

then result like this

 - 1  1  2  test   content1
 - 2  1  1  test2   content2

but I need get result like this :

 - 1  linux  Stif   test   content1
 - 2  linux  Jak    test2   content2

How do I do that?


with join you can make the query that you want try this:

function getall(){
   $this->db->select('*, category.id as category_id, users.id as user_id');
   $this->db->join("users", "users.id = posts.idu");
   $this->db->join("category", "category.id = posts.idc"); 
   $this->db->order_by("posts.id", "desc"); 
   $query = $this->db->get();
   return $query->result();


Need Your Help

Joomla module install.sql not executing

sql joomla joomla-module

I have the following file install.sql in my site module's /sql folder. And I'm referencing it from my module's .xml file like so:

Can I increase the size of a statically allocated array?

c arrays static-allocation

I know its possible to increase the size of a dynamically allocated array.