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



RSS Twitter
Articles Databases

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

by: Geno Timlin
|
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);
}
?>

« Previous Page
1
|
2
|
3
|
4
|
5
|
6
|
7
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Geno Timlin

Comment:



Comment:

(Maximum characters: 1200). You have characters left.