#native_company# #native_desc#
#native_cta#

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

By Geno Timlin
on June 1, 2004

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;

}

?>



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