Hello, I'm doing a system to fetch the data in the database for the month only it gives the following error
Fatal error: Uncaught Error: Call to undefined method mysqli :: getInstance ()
It's all right in my eyes.
This is a query.
<?php
require('config.php');
class Usuario {
private $connection = null;
public function __construction($connection) {
$this->connection = $connection;
}
public function carregaSetores($data) {
try {
$Query = "SELECT
s.nome,
s.snome,
s.telefone,
s.refeicao,
s.bebida,
s.data,
s.hora,
s.npessoa,
s.nmesa,
FROM pedido
";
$p_sql = mysql::getInstance()->prepare($Query);
$_retorno = array();
if ($p_sql->execute()) {
while ($_result = $p_sql->fetch(PDO::FETCH_ASSOC)) {
$_retorno[] = $_result;
}
}
return $_retorno;
} catch (PDOException $e) {
echo $e->getMessage();
}
}
}
?>
and this is the code that generates the report.
<?php
require('config.php');
require('usuario.php');
$data = $_POST["data"];
$Usuario = new Usuario($dbConnetion);
$listaDados = $Usuario->carregaSetores($data);
if(!empty($listaDados)){
foreach($listaDados as $value){
//echo "<pre>"; print_r($value); exit;
echo "<tr>";
echo "<td><center>". $value["nome"] ."</center></td>";
echo "<td><center>". $value["snome"] ."</center></td>";
echo "<td><center>". $value["telefone"] ."</center></td>";
echo "<td>". $value["refeicao"] ."</td>";
echo "<td>". $value["bebida"] ."</td>";
echo "<td><center>". $value["data"] ."</center></td>";
echo "<td><center>". $value["hora"] ."</center></td>";
echo "<td>". $value["npessoa"] ."</td>";
echo "<td>". $value["nmesa"] ."</td>";
echo "</tr >";
}
}
?>
and what connects to the database
<?php
// Creating a database connection
$connection = mysqli_connect("localhost", "root", "", "peixaria");
if (!$connection) {
die("Database connection failed: " . mysqli_connect_error());
}
// Selecting a database
$db_select = mysqli_select_db($connection, "peixaria");
if (!$db_select) {
die("Database selection failed: " . mysqli_connect_error());
}
?>
The error would be in this line
$ p_sql = mysql :: getInstance () -> prepare ($ Query);