In appedit.php we display a form loaded with the vehicle data. The form POSTs to the appupdate.php script.
<?php
$id = $_GET["id"];
$dao = new VehicleDAO();
$vo = $dao->findByPK($id);
...
<input type="text" name="year" value="<?=$vo->year?>" />
<input type="text" name="model" value="<?=$vo->model?>" />
<input type="text" name="color" value="<?=$vo->color?>" />
...
?>
In appupdate.php, we create an empty
VehicleVO object and read in the data from the form. The VO
is then passed to the update() method of a VehicleDAO object.
VehicleVO object and read in the data from the form. The VO
is then passed to the update() method of a VehicleDAO object.
<?php
$vo
= new VehicleVO();
$dao = new VehicleDAO();
$vo->readForm();
$records_updated = $dao->update($vo);
...
?>
Summary
Now this is NOT the pure Model/View/Controller design that J2EE developers are all drooling over these
days, but it’s close enough for horseshoes. I am sure that with PHP 5 deeper object oriented capabilities,
a better MVC design will arise. But I believe this is a pretty good object oriented design for now.
days, but it’s close enough for horseshoes. I am sure that with PHP 5 deeper object oriented capabilities,
a better MVC design will arise. But I believe this is a pretty good object oriented design for now.
Also, I’ve included a PHP page that builds the VO and DAO classes for you. How much
easier can you get it?
easier can you get it?
Geno Timlin