Welcome Guest, Not a member yet? Register   Sign In
Getting a users name from id
#5

[eluser]cahva[/eluser]
Didnt you say you could do it "oldschool" Smile Its a simple mysql query, just like "oldschool" unless you want to use active record.

I dont know the fields but it should look something like this(and put your database related things in model):

Code:
class Posts_model extends Model {
    
    function __construct()
    {
        parent::__construct();
    }
    
    function get_all()
    {
        $this->db->select('*')
                ->from('posts')
                ->join('users','users.id = posts.uid');
                
        $query = $this->db->get();
        
        return $query->result_array();
    }
}

Theres select('*') but you should put the fields you are going to use there.

Then in the controller:
Code:
$this->load->model('posts_model','posts');
$content['posts'] = $this->posts->get_all();

Look in the user guide for more information about active record.


Messages In This Thread
Getting a users name from id - by El Forum - 04-26-2010, 05:15 AM
Getting a users name from id - by El Forum - 04-27-2010, 12:15 AM
Getting a users name from id - by El Forum - 04-27-2010, 02:20 AM
Getting a users name from id - by El Forum - 04-28-2010, 01:02 PM
Getting a users name from id - by El Forum - 04-28-2010, 02:26 PM
Getting a users name from id - by El Forum - 04-28-2010, 02:42 PM
Getting a users name from id - by El Forum - 04-29-2010, 04:22 AM
Getting a users name from id - by El Forum - 04-29-2010, 04:50 AM
Getting a users name from id - by El Forum - 04-29-2010, 12:15 PM
Getting a users name from id - by El Forum - 04-29-2010, 12:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB