php - Class for PDO vs Variable PDO -
so using pdo:
config.php
$pdo = new pdo('mysql:host='.mysql_host.';dbname=driptone', mysql_user, mysql_password); try { $pdo->setattribute(pdo::attr_errmode, pdo::errmode_exception); } catch(pdoexception $e) { echo 'error: ' . $e->getmessage(); }
and include in every class needs connection.
usage:
$this->property = $pdo->prepare();
i've seen people doing via class, eg class database. running through constructor, , wanted ask,
what difference between them? how create database handling using pdo , in it's own class?
just extend pdo
class pdo_class extends pdo { ... }
Comments
Post a Comment