I'm trying to initialize an object in my index.php, however it often requires an argument so I can't initialize and use it.
I created an interface that is implemented by a MYSQL function, used in a "User" Model that executes a "search" function, after that I try to keep it in my index.php, but it requires arguments. What kind of arguments should I pass to perform the execution? I dont have any constructor function on Database file. Just a class MYSQL which i want to use who makes the connection with the function conectar() and it implements Interface.
<?php
namespace Source\Model;
use Source\Controller\DatabaseInterface;
class User
{
private $dbConnection;
public function __construct(DatabaseInterface $dbConnection)
{
$this->dbConnection = $dbConnection;
}
public function search($dbConnection)
{
$query="SELECT * from categoria";
$queryrun=mysqli_query($dbConnection, $query);
echo '<pre>';
var_dump($queryrun);
echo '</pre>';
}
}
Index.php
<?php
require __DIR__ . "./vendor/autoload.php";
use Source\Model\User;
$teste = new User();