Azure表存储PHP如果实体属性未定义导致错误

i have data stored in Azure table storage.. For each customer i have some attributes ( Like Name, email, address Properties). For some customer we don't have these attributes. ( added later on during Journey)

When i try to pull a customer Entity Properties via PHP and if that Property is not defined it raise fatal error.

E.g in Below code i have additional_attribute entity Property, which is defined for few customers only. Doesn't have that entity for all customers. If i use below code it will raise fatal error.

How to handle this exception.

$tableRestProxy = ServicesBuilder::getInstance()->createTableService($this->connectionString);
$filter = "PartitionKey eq '" . $this->apiusr . "' and RowKey eq '" . $this->apiusr . "' and apiseceret eq '" . $this->apipass . "'";

$entities = $result->getEntities();
if (count($entities) > 0 ) 
{
$this->user_valid = true;
$this->cid = $entity->getProperty("cid")->getValue();
**$this->additonal_attribute = $entity->getProperty("additiona_attributes")->getValue()**; <--------------
}

Since this is NO SQL database, what is solution for this in PHP? ( Schema for each row can be different). How to handle this in PHP?

The code i am using is from http://www.windowsazure.com/en-us/develop/php/how-to-guides/table-service/

Haven't worked with PHP (so I may be wrong) but could you be getting this error because you're trying to get the value of a null object? when you call getProperty() on an entity which does not have this attribute, it returns null and then you call getValue() on that null object.

I looked up the source code for PHP SDK on GitHub and found another method which you can try. That method is getPropertyValue($name). Using this if the attribute is not found in the entity, you will get null value back. So your code would look something like:

$this->additonal_attribute = $entity->getPropertyValue("additiona_attributes")