insert into
didn't work .
I have tried mysqli connection and it doesn't work.
Check code please and tell me whats wrong.
<?php
require_once "DBController.php";
class Rate extends DBController
{
function getAllPost()
{
$query = "SELECT * FROM storedproducts";
$postResult = $this->getDBResult($query);
return $postResult;
}
public function AddRating($rating, $id) {
$query = $this->conn->prepare("insert into stored_rating ( rating , stored_id) VALUES (?,?)");
$query->execute([$rating, $id,]);
}
public function getRateAverage($id) {
$query = $this->conn->prepare("SELECT AVG(rating) FROM `stored_rating` WHERE stored_id=?");
$params = array(
array(
"param_type" => "i",
"param_value" => $id
)
);
$this->bindParams($query,$params);
$query->->execute();
$rsult->fetchColumn();
return $rsult;
}
// $query = "insert into stored_rating ( rating , stored_id) VALUES (?,?)";
// $statement->execute([$rating, $id,]);
function updateRatingCount($rating, $id)
{
$query = "UPDATE storedproducts SET rating = ? WHERE ID_Stored= ?";
$params = array(
array(
"param_type" => "i",
"param_value" => $rating
),
array(
"param_type" => "i",
"param_value" => $id
)
);
this->updateDB(updateDB,$params);
}
}