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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -