I'm starting to make a PHP class for a database connection, i've made a constructor and in that constructor i make the connection to the database.
class mysqli_db{
function __construct()
{
$conn = mysqli_connect("ip","username","password");
if (!$conn) {
echo "Cannot connect to server";
exit();
}
$db = mysqli_select_db($conn,"silvaag166_prj");
if (!$db) {
echo "Cannot select database";
exit();
}
}
}
I understand de part above but now i want to make a function to select data from the database so i've made this:
public function selectAll($tablename)
{
return mysqli_query(?,"SELECT * FROM ".$tableName);
}
At the ? i need to add the connection string and that can be found in the constructor. How do i need to insert the connectionstring at the ?.