Using same MySQL Connection in different PHP pages

前端 未结 5 2004
一生所求
一生所求 2021-01-19 03:46

I am creating a simple Web Application in PHP for my college project. I am using the MySQL database.

I connect to the database in login.php. After connection I assig

5条回答
  •  遥遥无期
    2021-01-19 04:30

    What I normally have is a Connection class that pages will require in order to establish a connection. Something along the lines of:

    class Connection    {
        public $dbConnection = null;
        public $isConnectionActive = false;
        private $dbServer = null;
        private $dbCatalog = null;
        private $dbUser = null;
        private $dbPassword = null;
    }
    

    This class handles opening and closing of the connection on any pages.

提交回复
热议问题