亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

數(shù)據(jù)庫連接但單例模式

原創(chuàng) 2019-05-11 19:31:59 147
摘要:class  Db{    //私有化構(gòu)造方法    private function  __construct()    {    }     //私有化克隆方法    private function __clone()    { &n

class  Db{
   //私有化構(gòu)造方法
   private function  __construct()
   {
   }
    //私有化克隆方法
   private function __clone()
   {
       // TODO: Implement __clone() method.
   }

   protected  static  $db;
   //內(nèi)部實(shí)例化方法
   public  static  function dbInstant($host,$user,$password,$dbname){

       if(isset(self::$db)){
           return self::$db;
       }else{
           return self::$db=new PDO("mysql:".$host.";".$dbname,$user,$password);
       }

   }
}

$db = Db::dbInstant('127.0.0.1','root','root','ceshi');

批改老師:查無此人批改時(shí)間:2019-05-13 09:36:04
老師總結(jié):完成的不錯(cuò)。編程還有很多模式。多了解,可以更好的提高能力。繼續(xù)加油

發(fā)佈手記

熱門詞條