Overriding Parent Methods

class DB {
 public $result; function getResult() {
  return $this->result;
 } function query($sql) {
  error_log("query() must be overridden by a database-specific child");
  return false;
 }
}class MySQL extends DB {
 function query($sql) {
  $this->result = mysql_query($sql);
 }
}

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.