Close MySQL connection (PHP)

前端 未结 3 1265
臣服心动
臣服心动 2021-01-15 07:56

I wrote a class to create an automated connection with MySQL and create queries. Here\'s how it looks like:

include(\"constants.php\");

class MySQLDB {
             


        
3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-15 08:36

    You probably don't need this if you read the manual it says:

    Using mysql_close() isn't usually necessary, as non-persistent open links are automatically closed at the end of the script's execution.

    If you still want to use it you need to but the function inside of the class...

          function close() {
              mysql_close($this->connection);
          }
              // and so on...
     }
    $mysql = new MySQLDB;
    

提交回复
热议问题