小编Alt*_*ini的帖子

静态实例变量的析构函数方法?

这是我的课:

class MySQLDB extends PDO{

        private $_connection;
        private static $_instance; //The single instance
        private $_host = MYSQL_SERVER_NAME;
        private $_username = MYSQL_SERVER_USERNAME;
        private $_password = MYSQL_SERVER_PASSWORD;
        private $_database = MYSQL_SERVER_DBNAME;
        /*
        Get an instance of the MySQLDB
        @return Instance
        */
        public static function getInstance() {
                if(!self::$_instance) { // If no instance then make one
                        self::$_instance = new self();
                }
                return self::$_instance;
        }

        // Get PDO MySQL connection
        public function getConnection() {
                return $this->_connection;
        }

    public function __construct(){
        try {
            $this->_connection = …
Run Code Online (Sandbox Code Playgroud)

php mysql oop singleton pdo

3
推荐指数
1
解决办法
1167
查看次数

标签 统计

mysql ×1

oop ×1

pdo ×1

php ×1

singleton ×1