OOP yinelenen uzanır

0 Cevap php

Ben, hem de SQL sınıfından genişletilmesi iki sınıfları var

gibi bu:

class SQL {  
    private $db_connect_id;  
    function connect($ad, $db, $us, $pa){  
        $this->db_connect_id = mssql_connect($ad, $us, $pa);  
        mssql_select_db ($db, $this->db_connect_id) or die('sql error');  
    }  
    function sql_query($query = ""){  
        unset($this->query_result);  
        if($query != ""){  
            $this->num_queries++;  
            $this->query_result = @mssql_query($query, $this->db_connect_id) or die('error query');  
        }  
        if($this->query_result){  
            unset($this->row[$this->query_result]);  
            unset($this->rowset[$this->query_result]);  
            return $this->query_result;  
        }  
    }   
}

class WEB extends SQL {  
    function __construct(){ $this->connect(params) }  
    function __destruct(){ $this->disconnect() }  
}

class AUTH extends SQL {  
    function __construct(){ $this->connect(params) }  
    function __destruct(){ $this->disconnect() }  
}

sorun olduğunu ben ikisini de ararsanız

$WEB = new WEB();  
$AUTH = new AUTH();

the $WEB won't work anymore. It loses its connection with the database and it changes the db_connect_id with the db_connect_id from AUTH...
I think this is a stupid question and I'm too tired, but I have to finish. Where I'm doing wrong? Thank you

0 Cevap