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



RSS Twitter
Articles Databases

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

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

« 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.