On page 95 of the book there is some bolded code there that modifies the getSubCategories function in the MCats model. could someone please help me understand what exactly it's doing. The book gives no explanation of this code.
PHP Code:
foreach ($Q->result_array() as $row){
$sql = "select thumbnail as src
from products
where category_id=".id_clean($row['id'])."
and status='active'
order by rand() limit 1";
$Q2 = $this->db->query($sql);
if($Q2->num_rows() > 0){
$thumb = $Q2->row_array();
$THUMB = $thumb['src'];
}else{
$THUMB = '';
}
$Q2->free_result();
$data[] = array(
'id' => $row['id'],
'name' => $row['name'],
'shortdesc' => $row['shortdesc'],
'thumbnail' => $THUMB
);
}