EducateYourself
EducateYourself

Reputation: 979

Codeigniter getting the results from db

I wonder if the following codes do the same thing?

1

if ($query->num_rows() == 1) {     
$row= $query->row_array(); 
       $path = $row['path'];
       $photo = $row['photo'];
}

2

if ($query->num_rows() == 1) {          
     foreach ($query->result() as $row){
             $path = $row->path;
             $photo = $row->photo;
             } 
}

Upvotes: 0

Views: 26

Answers (1)

Don Dickinson
Don Dickinson

Reputation: 6258

Yes. One gets the result as an object the other an associative array. Same result.

Upvotes: 2

Related Questions