<?php
class DatabaseConnect{
private $mysql_host = 'localhost';
private $username = 'root';
private $password = '';
private $database = 'hardware.pl';
private $pdo;
public function __construct(){
try {
$this->pdo = new PDO('mysql:host='.$this->mysql_host.';dbname='.$this->database.';charset=utf8', $this->username, $this->password, [
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
]);
}
catch(PDOException $e) {
echo $e->getMessage();
}
}
public function getPDO(){
return $this->pdo;
}
}
?>
<?php
$PDO = new DatabaseConnect;
$query = $PDO->getPDO();
$id1 = 1;
$id2 = 2;
$id3 = 3;
$id4 = 4;
$id5 = 5;
try{
$query->prepare('SELECT Name, Price, Discount, Quantity FROM products WHERE ID = :id1 OR ID = :id2 OR ID = :id3 OR ID = :id4 OR ID = :id5');
$query->bindValue(':id1', $id1, PDO::PARAM_INT);
$query->bindValue(':id2', $id2, PDO::PARAM_INT);
$query->bindValue(':id3', $id3, PDO::PARAM_INT);
$query->bindValue(':id4', $id4, PDO::PARAM_INT);
$query->bindValue(':id5', $id5, PDO::PARAM_INT);
$query->execute();
}
catch(PDOException $e){
echo $e->getMessage();
exit();
}
?>
Zwracany jest następujący błąd: Fatal error: Uncaught Error: Call to undefined method PDO::bindValue() in C:\Users\jakub\Documents\GitHub\Hardware-shop\Shop\Templates\home.php:14 Stack trace: #0 C:\Users\jakub\Documents\GitHub\Hardware-shop\Shop\config.php(9): require_once() #1 C:\Users\jakub\Documents\GitHub\Hardware-shop\Shop\Templates\core.php(239): loadFile('Templates/home....') #2 C:\Users\jakub\Documents\GitHub\Hardware-shop\Shop\config.php(9): require_once('C:\\Users\\jakub\\...') #3 C:\Users\jakub\Documents\GitHub\Hardware-shop\Shop\index.php(22): loadFile('Templates/core....') #4 {main} thrown in C:\Users\jakub\Documents\GitHub\Hardware-shop\Shop\Templates\home.php on line 14
Czy może ktoś mi powiedzieć gdzie popełniłem błąd? Siedzę nad tym kodem już trochę i nie mogę znaleźć rozwiązania problemu