<?php/** * ipdo.php * * discription * * @filename ipdo.php * @version v1.0 * @update 2011-4-27 * @author Randy.hon G * @contact homingway@163.com * @package PDO *///db configdefine (' db_host ', ' localhost ');d efine (' Db_port ', ' 3306 ');d Efine (' Db_user ', ' root ');d efine (' db_passwd ', ' 123456 ');d efine (' db_charset ', ' UTF8 '); class Ipdo {/** * the singlet On instance */static public $PDOInstance; /** * Creates a PDO instance representing a connection to a database and makes the instance available as a singleton * @return PDO */Public Function __construct () {$dsn = ' mysql:host= '. Db_host. '; Port= '. Db_port. '; Dbname= '. db_name; $driver _options = Array (Pdo::mysql_attr_init_command = "SET NAMES". Db_charset); if (!self:: $PDOInstance) {try {self:: $PDOInstance = new PDO ($DSN, Db_user, db_passwd, $driver _options ); Self:: $PDOInstance->setattribute (Pdo::attr_errmode, pdo::errmode_exception); } catch (PdoexcEption $e) {die ($e->getmessage ()); }} return self:: $PDOInstance; }}//using $pdo = new Ipdo ();? >