ok... i have a fairly simple class that retrievs infomation about a node from a database and stores this infomation as properties of the clas itself. now i would like to extend the functionality of this class to enable me to set these properties manually and then call a createnew() method to add these new properties to the db.
ive been toying around with a few ideas, but the one i would really like to impliment is the use of the magic get and set methods. im really not sure how else to put it but i have a book that explains it a little but im also a little lost.
if there is anyone out there who knows what im talking about, could you please show me an example using this class.
<?php
class node
{
private $db;
public $id;
public $parent;
public $lbound;
public $ubound;
function __construct()
{
include('class.db.sqlite.php');
$this->db = new sqlite(DBPATH);
}
public function getnode($id)
{
if (!$this->db->result("SELECT parent,lbound,ubound FROM node WHERE id = $id")) {
throw new exception('node does not exist');
}
$result = $db->fetch();
$this->parent = $id;
$this->parent = $result['parent'];
$this->lbound = $result['lbound'];
$this->ubound = $result['ubound'];
}
}
?>
this isn't my actual class, but something i knocked up at work just to use as an example. hope its not too much trouble, much appreciated.