Posted by GameboyHippo on 10/16/07 13:46
I have a get function that looks like this:
/**
* Magic function that gets properties
* @param mixed $var The property that should be retrieved
* @return mixed The value of the property. Returns null if property
doesn't exist
*/
function __get($var)
{
$special_properties = array('name');
if (!isset($this->data[$var]) && !in_array($var,$special_properties))
{
echo "Warning: $var is not a property for ".get_class($this)."!\n";
return null;
}
else{
switch ($var){
case 'name':
return $this->data['first_name'].' '.$this->data['last_name'];
break;
case 'office_phone':
case 'mobile_phone':
case 'other_phone':
return $this->to_phone_string($this->data[$var]);
break;
default:
return $this->data[$var];
}
}
}
Here's the question. Say I have a row in my database that has a null
value in the column other_phone. When it gets to the first if
statement !isset($this->data[$var]) it is going to evaluate to true
(in other words $this->data['office_phone'] is not set because it is
null). How do I evaluate if the column is merely not there instead of
not there or null?
Navigation:
[Reply to this message]
|