Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Syncing object property to database -- isset, empty, etc?

0 views
Skip to first unread message

lawpoop

unread,
Oct 9, 2009, 4:42:32 PM10/9/09
to
Hello all -

I'm working on an object that's basically an interface to a set of
database values.

On __construct, I don't really do much -- just look for a valid 'id'
value passed for a database row. There are a lot of other values in
the database that I'll want to get from the object, but not all the
time, so it seems to me a waste to load them all up on __construct.

So my thought then is to do some syncing to the database -- define the
properties, but only load their database values at the first
getProperty() call. I'll need to check whether the property has been
synched with the database, butometimes the value might actually be
NULL in the database, so a NULL property value won't tell me whether
I've pulled the value from the database or not.

My next thought is to use isset(), but would this work properly? From
this table http://www.php.net/manual/en/types.comparisons.php , it
looks like it returns FALSE on a null value -- so it won't tell me if
I've pulled a NULL value from the database.

What's the right way to test the value in this design?

0 new messages