【发布时间】:2013-12-17 03:13:48
【问题描述】:
我将数据存储在 Azure 表存储中。对于每个客户,我都有一些属性(如姓名、电子邮件、地址属性)。对于某些客户,我们没有这些属性。 (稍后在旅途中添加)
当我尝试通过 PHP 提取客户实体属性时,如果未定义该属性,则会引发致命错误。
例如,在下面的代码中,我有附加属性实体属性,它只为少数客户定义。并非所有客户都拥有该实体。如果我使用下面的代码,它会引发致命错误。
如何处理这个异常。
$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()**; <--------------
}
既然这不是 SQL 数据库,那么 PHP 中的解决方案是什么? (每行的架构可以不同)。如何在 PHP 中处理?
我使用的代码来自 http://www.windowsazure.com/en-us/develop/php/how-to-guides/table-service/
【问题讨论】:
标签: php azure azure-blob-storage azure-table-storage