Incorporating dbphp into your site

If you are using a standard java style class model which links back to the structure of your table then implementing dbphp functionality couldnt be easier. All you have to do is add a constructer to your class which tells dbphp which values in your class you want to link back to which columns in the database

Table structure

Column
Type
id
int (auto increment)
first_name
Varchar(64)
last_name
Varchar(64)

Normal class structure reflecting the data held within the table

dbphp tools helps you do this more quickly

  1. class Table extends DbOneToOne { 
  2.  
  3.    private $id = null; 
  4.    private $firstName = null; 
  5.    private $lastName = null; 
  6.  
  7.    public function Table(){ 
  8.       $this->setDbTable('table'); 
  9.       $this->setDbKey('id'); 
  10.       $this->add("first_name",$this->fistName);    
  11.       $this->add("last_name", $this->lastName); 
  12.    } 
  13.     
  14.     
  15.    public function getFirstName(){ 
  16.       return $this->firstName; 
  17.    } 
  18.     
  19.    public function setFirstName($firstName){ 
  20.       $this->firstName = $firstName; 
  21.    } 
  22.  
  23.    public function getLastName(){ 
  24.       return $this->lastName; 
  25.    } 
  26.     
  27.    public function setLastName($lastName){ 
  28.       $this->lastName = $lastName; 
  29.    } 
  30. }

Linking

In order for you to link this class with the table all you have to do is implement a constructor that ustilises the DbOneToOne functionality

banner

If you are unsure about object orientation or any of the other issues here please download and read the manual and the resources available on icurtain