I wonder if the following codes do the same thing?
-
if ($query->num_rows() == 1) { $row = $query->row_array(); $path = $row['path']; $photo = $row['photo']; } -
if ($query->num_rows() == 1) { foreach ($query->result() as $row) { $path = $row->path; $photo = $row->photo; } }
$row = $query->row_array(); [$path, $photo] = $row ?? [null, null];It is easy to identify therow_array()return data as an array or null.