我有数据库类和构造函数:
<?php
class Connection {
private $PDO;
function __construct() {
$username = 'root';
$password = 'password';
$PDO = new PDO('mysql:dbname=PROOV;host=localhost', $username, $password);
return $this->PDO;
}
}
?>
以及扩展它的另一个类:
<?php
//$query = 'SELECT part_description FROM SparePartRequests LIMIT 100';
include_once 'connection.php';
class Proov extends PDO {
public function returnRows() {
$sth = $this->prepare('SELECT part_description FROM SparePartRequests LIMIT 100');
$sth->execute();
$result = $sth->fetch();
return $result;
}
}
$proov = new Proov(); // <- this is line nr 19...
?>
它抛出异常:警告:PDO::__construct() 至少需要 1 个参数,0 在第 19 行的 /var/www/proov/proov1.php 中给出
我该如何解决我的问题?谢谢你的帮助!
谢谢你的帮助!