For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > December 2005 > RE: [PEAR] making DataObject::get() call other methods









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author RE: [PEAR] making DataObject::get() call other methods
Rob Agar

2005-12-14, 3:58 am


hi Jeff,

> Is there a way to have the get() method call other methods to do some
> parsing before it returns an object?


Yes, make a class that derives from DB_DataObject and override the get()
method, like this:

function get($k = null, $v = null)
{
// call DB_DataObject get method to fetch the data
$success = parent::get($k, $v);

if ($success)
{
// do your special stuff
}

return $success;
}

You'll also need to change the "extends" and "extends_location"
properties in your DBDO ini file, or wherever you setup the
configuration.

eg
extends_location = DB_DataObject_Ex.php
extends = DB_DataObject_Ex

hth,
Rob

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com