I want to create a PDO class for handling data base connections.
Here is what I have:
require('php/packages/store/store_db_settings.php');
class store_pdo
{
private $DBH; // Data Base Handler
function __construct()
{
$DBH = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
}
public function getHandler()
{
return $DBH;
}
}
I think this seems ok, however I am used to just using things like mysql_query
and not really sure what problems I could run into in the future. So I thought the experience here could offer guidance.
Is what I have sufficient? should I make my class Singleton, or use static functions? Is there a best practice?
I don't want to go with this, then I after have several other classes using it, discover that I should have written it differently.
P.S. I just noticed that the best-practices
tag is no longer allowed... does that mean questions like this are discouraged now too?