我已经为MySQL创建了一个类,但它似乎没有显示错误。
class MySQL
{
public static function connect(){
$confFile = new ConfigFile( AB_BASE_PATH . AB_CONFIG_FILE );
$Host = $confFile->getDbHost();
$Database = $confFile->getDbName();
$User = $confFile->getDbUser();
$Password = $confFile->getDbPwd();
$con = mysqli_connect($Host,$User,$Password,$Database) or die("Could not connect. " . mysql_error());
return $con;
}
public function query($SQL){
$r = mysqli_query($this->connect(),$SQL) or die(mysqli_error($this->connect()));
return mysqli_fetch_array($r);
}
}
这就是我调用查询的方式:
$Row = $MySQL->query("SELECT * FROM Contacts");