Having a Class with pre-built queries that can be altered is the main known method; but say that there is about 80 tables, each holding thousands of rows of data, it would take so long to write each of them queries...
I'd just like to understand why having an open connection in a main scope is actually a security issue - how can they "intercept" it?
Take for example:
// Main index page
$db = new PDO('mysql:host=x;dbname=x;','user','pass');
Would this be a threat and if so how? (since its never reverted back to null)
Or would this be a more secure method of doing the above since the instance is never saved?
final class DataCenter
{
public static function GetInstance()
{
return new PDO('mysql:host=x;dbname=x;','x','x');
}
}
$smpt = DataCenter::GetInstance()
->Prepare("SELECT * FROM x");
$smpt->Execute();
$smpt->FetchAll();
print_r($smpt);
If this is confusing, I apologise - I just want to know: if instancing a PDO connection which never dies or is reverted back to null is a security issue, how so? Since the users cannot see the code.
Thanks in advance.