<?php
class StudentViever
{
private $db ;
public function __construct( PDO $db ) {
$this -> db = $db ;
}
public function returnResult( $array ) {
$request = $this -> db -> prepare ( "SELECT firstName, lastName, sex, section, exams, year FROM students LIMIT ?, ?;" ) ;
$request -> execute ( $array ) ;
$result = $request -> fetchAll ( ) ;
return $result ;
}
}
$SAT = new PDO( 'mysql:host=localhost;dbname=sat' , 'root' , '' ) ;
$SAT -> setAttribute ( PDO:: ATTR_ERRMODE , PDO:: ERRMODE_EXCEPTION ) ;
$test = new StudentViever( $SAT ) ;
print_r ( $test -> returnResult ( $array ) ) ;
PD9waHAKZXJyb3JfcmVwb3J0aW5nKC0xKTsKbWJfaW50ZXJuYWxfZW5jb2RpbmcoJ3V0Zi04Jyk7CgpjbGFzcyBTdHVkZW50VmlldmVyCnsKCXByaXZhdGUgJGRiOwoJCglwdWJsaWMgZnVuY3Rpb24gX19jb25zdHJ1Y3QoUERPICRkYil7CgkJJHRoaXMtPmRiID0gJGRiOwoJfQoJcHVibGljIGZ1bmN0aW9uIHJldHVyblJlc3VsdCgkYXJyYXkpewoJCSRyZXF1ZXN0ID0gJHRoaXMtPmRiLT5wcmVwYXJlKCJTRUxFQ1QgZmlyc3ROYW1lLCBsYXN0TmFtZSwgc2V4LCBzZWN0aW9uLCBleGFtcywgeWVhciBGUk9NIHN0dWRlbnRzIExJTUlUID8sID87Iik7CgkJJHJlcXVlc3QtPmV4ZWN1dGUoJGFycmF5KTsKCQkkcmVzdWx0ID0gJHJlcXVlc3QtPmZldGNoQWxsKCk7CgkJcmV0dXJuICRyZXN1bHQ7Cgl9Cn0KJFNBVCA9IG5ldyBQRE8oJ215c3FsOmhvc3Q9bG9jYWxob3N0O2RibmFtZT1zYXQnLCAncm9vdCcsICcnKTsKJFNBVC0+c2V0QXR0cmlidXRlKCBQRE86OkFUVFJfRVJSTU9ERSwgUERPOjpFUlJNT0RFX0VYQ0VQVElPTiApOwokdGVzdCA9IG5ldyBTdHVkZW50VmlldmVyKCRTQVQpOwokYXJyYXkgPSBhcnJheSgzLDUpOwpwcmludF9yKCR0ZXN0LT5yZXR1cm5SZXN1bHQoJGFycmF5KSk7