What is the equivalent of these two code in PDO
first:
  $row=mysql_fetch_array($query);
second:
 while($row=mysql_fetch_array($query)){
   $data[]=$row;
 }
i used these codes below but they are not exact same i guess, because the rest of the code didn't work.
$row = $query->fetch(PDO::FETCH_NUM);
and
 $data[] = $query->fetch(PDO::FETCH_ASSOC);