Kapat mysql bağlantısı (PHP)

0 Cevap php

MySQL ile otomatik bir bağlantı oluşturmak ve sorguları oluşturmak için bir sınıf yazdı. İşte benziyor nasıl:

    include("constants.php");

    class MySQLDB {
        var $connection;

        function __construct() {
            $this->connection = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die(mysql_error());
            mysql_select_db(DB_NAME, $this->connection);
            mysql_set_charset('utf8', $this->connection);
        }

        // SELECT ALL FROM
        function sf($unit, $table) {
            return mysql_query("SELECT ".$unit." FROM ".$table, $this->connection);
        }
            // and so on...
}

$mysql = new MySQLDB;

Now, i thought it would be better if i close the connection after i run some of this functions in other php pages. So how do i do that (the most effective way) in this class? I tried adding mysql_close($this->connection); at the end of the class (before the close bracket) but it gives me an error.

0 Cevap