[CDBI] How do you get the raw db value of a column rather than inflated object

Michael Peters mpeters at plusthree.com
Sat Feb 11 18:26:11 GMT 2006



Bill Moseley wrote:
> On Sat, Feb 11, 2006 at 12:56:05PM -0500, Michael Peters wrote:
> 
>>>    $object->my_column->id
>>
>>The downside to this approach is that if you just want the id (which you already
>> know since it's a column in $object's table) you can't juse use it. You have to
>>create a second object (which may require a trip to the database). In a tight
>>loop, this could cause some performance problems.
> 
> 
> If it's already known (i.e. the column was fetched when $object was
> created) then there's no extra trip to the database.  Just an extra
> method call.

Well, it depends on which columns you have marked as essential. So for the
column to be fetched when $object is created, you need it in $objet's list of
essential columns, but you can't be as liberal with "column"s essential columns
or it will cost you another trip.

-- 
Michael Peters
Developer
Plus Three, LP





More information about the ClassDBI mailing list