Introduction: This is a detailed page of the PDO Singleton model. It introduces the knowledge, skills, and experience related to PhP, PHP, MySQL, PDO, and Singleton PDO Singleton models, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 344671 'rolling = 'no'>
<? PHP/*** ipdo. PHP ** discription ** @ filename ipdo. PHP * @ version V1.0 * @ update 2011-4-27 * @ author Randy. hong * @ Contact homingway@163.com * @ package PDO * // dB configdefine ('db _ host', 'localhost'); define ('db _ port', '123 '); define ('db _ user', 'root'); define ('db _ passwd', '000000'); define ('db _ charset', 'utf8 '); class ipdo {/*** the singleton instance */static public $ pdoinstance;/*** creates 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 ;}} // use $ PDO = new ipdo ();?>
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/344671.html pageno: 4.