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_proper ties = array('name');
if (!isset($this->data[$var]) && !in_array($var, $special_proper ties))
{
echo "Warning: $var is not a property for ".get_class($th is)."!\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_strin g($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? 4 1156
On 16 Oct, 14:46, GameboyHippo <jasonwthomp... @gmail.comwrote :
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_proper ties = array('name');
if (!isset($this->data[$var]) && !in_array($var, $special_proper ties))
{
echo "Warning: $var is not a property for ".get_class($th is)."!\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_strin g($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.
On Oct 16, 9:11 am, Captain Paralytic <paul_laut...@y ahoo.comwrote:
On 16 Oct, 14:46, GameboyHippo <jasonwthomp... @gmail.comwrote :
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_proper ties = array('name');
if (!isset($this->data[$var]) && !in_array($var, $special_proper ties))
{
echo "Warning: $var is not a property for ".get_class($th is)."!\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_strin g($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.
I agree, however in practice, it doesn't work as expected. I'll check
out the other reply and see if that helps. Thanks!
On Oct 16, 9:19 am, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
On Tue, 16 Oct 2007 15:46:07 +0200, GameboyHippo
<jasonwthomp... @gmail.comwrote :
How do I evaluate if the column is merely not there instead of
not there or null?
http://nl2.php.net/manual/en/functio...key-exists.php
--
Rik Wasmus
Sweet! array_key_exist s works wonders! Thanks! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Robert Scheer |
last post by:
Hi.
I think I have some conceptual questions here. I have an asp.net web
application up and running and now I intend to use Atlas on some of my
pages. I have read that after installing Atlas, I need to create a
specific Atlas project. But what I need is to just adapt Atlas on
existing pages, so my questions are: Can I simply add Atlas controls
like UpdatePanel on an existing web application page? If so, do I need
to adjust some kind of...
|
by: iKiLL |
last post by:
Hi All,
My background is that i am new to C- Sharp and OOP. I have been working with
it for about 2 Weeks. I do have good experionce in developing in things like
VB6, COM, ASP, JavaScript and i have done some development with VB.Net but
it was not really done in an OOP fashion. i have Been asked to take over a
PDA application that has been writen in C-Sharp 2005.
My Question.
The application is holting in Memory an ArrayList of Tasks...
|
by: frostbb |
last post by:
Ok, stumped one more time, I'm trying to learn how to use a DataGridView in
place of the old DataGrid control.
QUESTION: How do I map the columns returned from a RunTime sql query to the
columns defined (defined columns collection) in a DataGridView??
i.e.
sql_query.display_name = dataGridView1.dg1vc_display_name
sql_query.name_last = dataGridView1.name_last
sql_query.name_first =...
|
by: =?Utf-8?B?UGV0ZXI=?= |
last post by:
I want to create a new column in a datatable from two existing columns. I
have no problem to create the new column using the datatable.columns.add
method. The problem is the value of the new column may become system.dbnull
since one of the two existing columns may have system.dbnull. How can I fix
it so the new column will get the value of the other column even the other
column is system.dbnull?
|
by: napatel04 |
last post by:
Hi everyone,
I would like to know if there is a quick query someone can help me
write for the following scenario. I think I can do this with VBA but
since this is suppose to be a temp. solution, I really do not want to
spend too much time on it.
I have two tables, 1 an old one which has work done in it with all the
necessary columns correctly populated with the data and the second one
I need which has the same columns but need to be...
| |
by: id10t error |
last post by:
Hello,
I am working on a project where I read in data from a flat file using
a dataset .The program than lets the user scan the barcode. The
problem is when the person scans a barcode on another form and the bar
code is not in the dataset I want to add the new barcode to the
dataset. Here is the code I for the orgianal dataset. Can anyone help
me with this?
Private Sub Load_Load(ByVal sender As Object, ByVal e As
|
by: Romulo NF |
last post by:
Greetings,
I´m back here to show the new version of the drag & drop table columns (original script ). I´ve found some issues with the old script, specially when trying to use 2 tables with drag&drop on the same page (which was not possible). Now i´ve a new concept of the script, more object oriented.
I´ve also commented the whole code so you guys can easier understand it engine.
What exactly we need when trying to make a column drag &...
|
by: kostasgio |
last post by:
Hello, this is my first post here, i hope i'll find this forum usefull.
Although i did a search about my question, i didnt find what i need , because the question isnt exactly what it sounds.
Here's my scenario
I have a table that doesnt have an identity column, but does have unique rows depending on a combination of two columns.
the table's name is carowner and the two columns i am talking about are iteid,cusid and they are both of...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |