Hey all attempting to create a small MVC kind of application. Currently working on database class.
I am running a connection to the database every time i call a functions however failing to connect successfully and being able to send the $con variable to the other functions to do whatever with.
class DB {
function __construct() {
$con = mysqli_connect("localhost","c3337015","c3337015");
if (mysqli_connect_errno())
{
return false;
}else{
return $con;
}
}
function getAll(){
if(isset($con)){
echo "Connection Successful";
echo "Do MYSQLI stuff $con = new mysqli etc etc etc";
}else{
echo "Connection Failed";
echo "Leave me alone";
}
}
}
echo $get = DB::getAll();