FragThePlanet
FragThePlanet

Reputation: 13

Codeigniter get 2 columns from result row()

I can't seem to find the documentation on how to do this correctly... can I not pull 2 columns from a result row?

my user model

// log user in
    public function login($email, $password){
        // validate
        $this->db->where('email', $email);
        $this->db->where('password', $password);

        $result = $this->db->get('users');

        if($result->num_rows() == 1){
            return $result->row(0)->user_id;
            return $result->row(2)->gamertag;
        } else {
            return false;
        }

Upvotes: 0

Views: 235

Answers (1)

hrishi
hrishi

Reputation: 1656

public function login($email, $password){
    // validate
    $this->db->select('user_id,gamertag');
    $this->db->where('email', $email);
    $this->db->where('password', $password);
    $this->db->from('users');
    $result = $this->db->get();

    if($result->num_rows() == 1){
        return $result->row();

    } else {
        return false;
    }

Upvotes: 2

Related Questions