I am writing a CLI application in PHP and I can't seem to understand why my MySQL Class that uses PDO will not get past the PDO or even error. I have made sure error reporting was enabled in my php.ini. PHP version is 7.1.3 on Windows 10.
Here is the MySQL Class. Please note it is not the whole class.
<?php
namespace App\Database;
class MySQL
{
private $Host;
private $DBName;
private $DBTable;
private $DBUser;
private $DBPassword;
private $DBPort;
private $PDO;
private $parameters;
private $bConnected = false;
public $querycount = 0;
function __construct($DBName, $DBTable)
{
$this->Host = getenv("DATABASE_HOST");
$this->DBPort = getenv("DATABASE_PORT");
$this->DBUser = getenv("DATABASE_USER");
$this->DBPassword = getenv("DATABASE_PASSWORD");
$this->DBName = $DBName;
$this->DBTable = $DBTable;
$this->Connect();
$this->$parameters = array();
}
private function Connect()
{
try{
echo "CENSOREDv1.0".PHP_EOL;
$this->PDO = new PDO("mysql:host=127.0.0.1;port=33061;dbname=store", "root", "password");
$this->PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->PDO->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
echo "CENSOREDv1.1".PHP_EOL;
$this->bConnected = true;
} catch (\PDOException $e){
echo $e->getMessage();
die();
}
}
Please understand I have hard coded my PDO connection string as to attempt to remove that as a possible issue.
I have invoked my MySQL class in another file. The constructor and everything fires right up until the PDO connection string then nothing.
Please let me know if you would like any additional information and I will do my best to provide it.
Thank you in advance for any help!