Rev 26 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
<?php
class Client {
private static $TABLENAME = 'client';
private $id; // the unique id of the client
private $name; // client name for display
private $notes; // any notes about this client
/* constructor. Pass in id, name and notes. If id passed but not name
will attempt to load information from the database
*/
function __construct ( $id = '', $name = '', $notes = '' ) {
$this->id = $id;
$this->name = $name;
$this->notes = $notes;
if ( $this->id and ! $this->name ) {
$this->loadFromDatabase();
}
} // constructor
function loadFromDatabase () {
$query = "select name, notes from $TABLENAME where id = $this->id";
// loadFromDatabase
} // loadFromDatabase
function saveToDatabase () {
if ( $this->id ) { // we are doing an update
$query = "update $TABLENAME set name = $this->name, notes = $this->notes where id = $this->id";
// do the save
} else { // this is a new record
$query = "insert into $TABLENAME ( id, name, notes ) values ( null, $this->name, $this->notes" );
}
} // saveToDatabase
} // class Client
?>
Generated by GNU Enscript 1.6.5.90.