fork download
  1. <?php
  2.  
  3. class StudentViever
  4. {
  5. private $db;
  6.  
  7. public function __construct(PDO $db){
  8. $this->db = $db;
  9. }
  10. public function returnResult($array){
  11. $request = $this->db->prepare("SELECT firstName, lastName, sex, section, exams, year FROM students LIMIT ?, ?;");
  12. $request->execute($array);
  13. $result = $request->fetchAll();
  14. return $result;
  15. }
  16. }
  17. $SAT = new PDO('mysql:host=localhost;dbname=sat', 'root', '');
  18. $SAT->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
  19. $test = new StudentViever($SAT);
  20. $array = array(3,5);
  21. print_r($test->returnResult($array));
Runtime error #stdin #stdout #stderr 0.01s 20520KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Fatal error:  Uncaught exception 'PDOException' with message 'could not find driver' in /home/rEDDNB/prog.php:19
Stack trace:
#0 /home/rEDDNB/prog.php(19): PDO->__construct('mysql:host=loca...', 'root', '')
#1 {main}
  thrown in /home/rEDDNB/prog.php on line 19