<?php
abstract class aDB{
/*
*连接数据库,从配置文件读取配置信息
*/
abstract public function conn();
abstract public function query();
// abstract public function getAll();
}
class Mysql extends aDB{
public $link;
/*
*连接数据库,从配置文件读取配置信息
*/
public function conn(){
include 'config.php';
$this->link = new mysqli($cfg['host'], $cfg['user'], $cfg['pwd'], $cfg['db']);
var_dump($this->link);
}
public function query($sql){
return $this->link->query($sql);
}
// public function getAll($sql){
// $res = $this->query($sql);
// var_dump($res);
// }
}
$mysql = new Mysql();
$mysql->conn();
?>