fork download
  1. <?php
  2. namespace app\models;
  3. class db{
  4. protected $dbh;
  5. public function __construct(){
  6. $this->dbh = new \PDO('mysql:host=127.0.0.1;dbname=students', 'root', '');
  7. }
  8. public function execute($sql, $class){
  9. $sth = $this->dbh->prepare($sql);
  10. $res = $sth->execute();
  11. if (false !== $res) {
  12. return $sth->fetchAll(\PDO::FETCH_CLASS, $class);
  13. }
  14. }
  15. }
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
Standard output is empty