I put it here first too :D just before your reply.
Thank you for your time and help!
I put it here first too :D just before your reply.
Thank you for your time and help!
I have been going over each line of my code for about the last hour or so if not more. I found some discrepancies in my variables. I used in a couple places $this->$parameters
or other variations which didn't seem to cause an error for some reason but rendered the code inoperable. I'm not sure why it wasn't throwing an error about the variables but it would seem that is what caused my issue.
Thank you for your time and help!
So it doesn't time out. I can connect with SQL Workbench to the Docker container running on my local machine. I have tested with the MySQL instance not running and it almost imediatly times out. Vardumping the $this->PDO
provides no data at all which I also found really weird. I have also changed line 32 to new \PDO(...)
as it not part of the namespace either.
I have had the script running for the past 5 minutes and recieved no error or timeout on the SQL request it just hangs still.
$this->PDO
is setting private $PDO;
Sure I wasn't sure if that was frowned upon. Here are the other places I have posted it.
If I remember right it is needed to access global class outside of the namespace.
Someone on stackoverflow pointed out it was “wrong” when it didn’t have it then proceeded to not help any further.
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!