G
Guest
Guest
Following (pseudo)code want work, any ideas?
var $res;
class c{
function queryDB($query){
$DB=mysql_connect($host,$usr...);
mysql_select_db($DBname);
$this->res=mysql_query($query);
mysql_close($DB);
}
function get(){
return mysql_get_assoc($this->res);
}
}
class a extends c{
function query($query){
c::queryDB($query);
}
}
class b extends c{
function query($query){
c::queryDB($query);
}
}
now im trying to use these classes in the folowing way:
$a1=new a();
$b1=new b();
$a1->query("SELECT * FROM tableA");
$aElm=$a1->get();
//no prob till here
$b1->query("SELECT * FROM tableB");
$bElm=$b1->get();
now i get no valid sql result or cannot connect to DB errors depending on whether i close the connection or not (//mysql_close())
Where is the bug?
var $res;
class c{
function queryDB($query){
$DB=mysql_connect($host,$usr...);
mysql_select_db($DBname);
$this->res=mysql_query($query);
mysql_close($DB);
}
function get(){
return mysql_get_assoc($this->res);
}
}
class a extends c{
function query($query){
c::queryDB($query);
}
}
class b extends c{
function query($query){
c::queryDB($query);
}
}
now im trying to use these classes in the folowing way:
$a1=new a();
$b1=new b();
$a1->query("SELECT * FROM tableA");
$aElm=$a1->get();
//no prob till here
$b1->query("SELECT * FROM tableB");
$bElm=$b1->get();
now i get no valid sql result or cannot connect to DB errors depending on whether i close the connection or not (//mysql_close())
Where is the bug?