簡介:這是PDO單例模型的詳細頁面,介紹了和php,php, mysql, pdo, 單例 PDO單例模型有關的知識、技巧、經驗,和一些php源碼等。
class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=344671' scrolling='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', '3306');define('DB_USER', 'root');define('DB_PASSWD', '123456');define('DB_CHARSET','utf8');class IPDO { /** * The singleton 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; }}//使用$pdo = new IPDO();?>
愛J2EE關注Java邁克爾傑克遜視頻站JSON線上工具
http://biancheng.dnbcw.info/php/344671.html pageNo:4