Yesterday i found the wonderfull world of php classes, i do understand how they work and how they look like, but i never tried to really program in it…
after programming a complete database class, including query’s and stuff.
i wanted to do a class for a news system… problem is, you need to connect and send query’s then… here is where i found my first problem.
class Database{
function Database($settings){
// some code
}
function connect(){
// some code
}
function close(){
// some code
}
function query($query){
// some code, returning the result in array
}
}
$Database = new Database($settings);
class News{
function show($limit){
$Database->connect();
$Array = $Database->query("some query");
return $Array;
}
}
$News = new News;
$News->show(5);
i know this dozn’t work, but you all get the idea, what is correct code for this?