Without checking the return value of "prepare" if "exec" is used then it will cause Fatal Error.
"PHP Fatal error:  Call to a member function execute() on a non-object "
To avoid this error,need to check return value as following:
<?php
 $db = new SQLite3('school.db');
 if($stmt = $db->prepare('SELECT id,student_name FROM classTen '))
 {
         $result = $stmt->execute();
         $names=array();
         while($arr=$result->fetchArray(SQLITE3_ASSOC))
         {
          $names[$arr['id']]=$arr['student_name'];
         }
}
?>