#native_company# #native_desc#
#native_cta#

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

By Geno Timlin
on June 1, 2004

The Base Value Object
The Base VO has a number of methods that assist in reading forms. Another method that could be
implemented here might be a date formatting method. Different databases return date values in
many different formats. To keep consistency, you may want to do some string manipulation with
the date values to keep them all looking the same.

The Extended Value Object

The VehicleVO class has five properties that reflect the five columns in the vehicles table.
A default constructor exists to create an empty VO or if given arguments, a VO filled with data:

<?php

// create a new VO

function VehicleVO($vehicleid0$year""$make"",

                   
$model""$color""$price0.00

{

    
$this->vehicleid $vehicleid;

    
$this->year $year;

    
$this->make $make;

    
$this->model $model;

    
$this->color $color;

    
$this->price $price;

}

?>



Other methods the VO includes are:

function equals($vo)
Compares itself to another VehicleVO object. Returns true or false.
function copy($vo)
Copies the contents of another VehicleVO object.
function readForm()
Reads values from the $_POST array.
function readQuery()
Reads values from the $_GET array.
function toXML()
Returns a string that contains it’s data represented as an XML node.
function toString()
Returns a string that contains a delimited line of data.
function getPK()
Return the value of the primary key field.

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