You are here: Re: Existing columns vs. Null columns question « PHP Programming Language « IT news, forums, messages
Re: Existing columns vs. Null columns question

Posted by Captain Paralytic on 10/16/07 14:11

On 16 Oct, 14:46, GameboyHippo <jasonwthomp...@gmail.com> wrote:
> 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?

If $this->data['office_phone'] is set to NULL then I would expect !
isset($this->data[$var]) to evaluate to false, because !isset($this-
>data[$var]) IS set.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация