zamalek 100
zamalek 100

Reputation: 55

How to return a class without array in Code Igniter

I have function that returns a Class in Array like this :

function getInfo($ev_id){
    $query = $this->db->query("SELECT * FROM events,users 
    where events.ev_user_id = users.id  
    and ev_id = $ev_id");
    $result = $query->result();
    return $result[0];        
}

This function returns a data Array, so I need to use the result to put it in input type to show it for user.

I need to use :-

$eventinfo->ev_text

Not to use an fetch array to display it like $eventinfo->ev_text

Upvotes: 0

Views: 99

Answers (1)

Kanishka Panamaldeniya
Kanishka Panamaldeniya

Reputation: 17586

use

$query->row() instead of $query->result()

 $result = $query->row();
    return $result;  

now you can use

$eventinfo->ev_text

with out looping

Upvotes: 0

Related Questions