- function findWhere($where = “”, $orderby = “”) –
- Returns an array of VehicleVO’s based on WHERE clause fragments.
For example:
<?php
$dao
= new VehicleDAO();
$volist = $dao->findWhere("(year > '1999') AND (make='Ford')");
foreach($volist as $vo)
{
echo("$vo->year $vo->model $vo->color<br />");
}
?>
The above would produce a list of Ford vehicles made in the year 2000 or later.
You can easily add your own data access custom methods:
<?php
function findByPrice($price, $gtlt)
{
$this->sql = $this->SQL_SELECT;
$voList = array();
$where = "WHERE ( price $gtlt $price) ";
$this->sql .= $where;
$this->exec($this->sql);
while($row = $this->getObject())
{
$vo = new VehicleVO(
$row->vehicleid,
$row->year,
$row->make,
$row->model,
$row->color,
$row->price
);
array_push($voList, $vo);
}
return $voList;
}
?>