#native_company# #native_desc#
#native_cta#

Value Objects and Data Access Objects with PHP 4.2.x Page 3

By Geno Timlin
on June 1, 2004

You can add any other methods you may need to the VO. For example, if you wanted to have a method
that returned the vehicle year, make and model with the year in red but the rest of the text black:

<?php

function getDescription() 

{

    
$buf "<font color='#ff0000'>";

    
$buf .= $this->year "</font>";

    
$buf .= "<font color='#000000'>";

    
$buf .= $this->make " " $this "</font>";

    return 
$buf;

}

?>



The Base Data Access Object
The base DAO provides methods to the VehicleDAO class (and any other classes that extend it)
that call database specific PHP methods to access the database. The base DAO could be used on
it’s own to provide data access on a PHP page, but in keeping with the MVC concepts, we use it
as an abstract class whose methods are implemented by objects that know about specific entities
in the database.
The Extended Data Access Object
The VehicleDAO class implements the functionality of the base DAO and transfers data between
VehicleVO’s and the database. The constructor calls the base DAO’s constructor which establishes
the connection to the database.

<?php

function VehicleDAO($dbserver=""$dbname=""$dbuser=""$dbpass=""

{

    
parent::BaseDAO($dbserver$dbname$dbuser$dbpass);

}

?>



1
|
2
|
3
|
4
|
5
|
6
|
7