I have (oh so cleverly) begun to develop an object-oriented system using PHP that will correspond to my MySQL database. This is proving to be much more challenging because, despite PHP 5's attempts, this would've been ten thousand times easier to do with Java.
Let's say I have a class called [FONT="Lucida Console"]Base[/FONT]:
<?php
abstract class Base{
private $mySQL = array('host' => '', 'username' => '', 'password' => '', 'database' => '', 'connection' => null);
protected $id;
function __construct($id){
$this->id = $id;
foreach($this->mySQL as $key => &$value) $$key = $value;
if(!$connection){
$connection = mysql_connect($host, $username, $password);
mysql_select_db($database);
}
}
function delete(){
$exe = mysql_query('SELECT * FROM '.get_class(/* ... */).' WHERE id = '.$this->id.';';
return mysql_num_rows($exe);
}
abstract function delete_($id){
$exe = mysql_query('SELECT * FROM '.get_class(/* ... */).' WHERE id = '.$id.';';
return mysql_num_rows($exe);
}
}
class User extends Base{
function __construct($uid){
parent::__construct($uid);
}
}
?>
Assuming [FONT="Lucida Console"]User[/FONT] is a table in my database, what can I put into the [FONT="Lucida Console"]get_class[/FONT] statement in the [FONT="Lucida Console"]Base[/FONT] class' [FONT="Lucida Console"]delete[/FONT] and [FONT="Lucida Console"]delete_[/FONT] functions so as to obtain the class name of the child class?