2016-09-30 82 views
0

我想使用Azure的PHP SDK将值附加到Azure表存储中的现有属性。例如:将值附加到实体的属性Azure表存储

PartitionKey: PartitionValue | RowKey: RowValue | PropertyValue -> Value1

我要追加到Value2Value1这样的:

PartitionKey: PartitionValue | RowKey: RowValue | PropertyValue -> Value1:Value2

这可能吗?并且Azure SDK for PHP的insertOrMerge实体有可能吗?

回答

0

您可以使用updateEntity()更新表存储中实体的PropertyValue。

E.G.

$tableRestProxy = ServicesBuilder::getInstance()->createTableService($connectionString); 

try { 
    $result = $tableRestProxy->getEntity("{table}", "{PartitionKey}", "{RowKey}"); 
} 
catch(ServiceException $e){ 
    $code = $e->getCode(); 
    $error_message = $e->getMessage(); 
    echo $code.": ".$error_message."<br />"; 
} 

$entity = $result->getEntity(); 

$entity->setPropertyValue("{PropertyValue}",$entity->getPropertyValue("{PropertyValue}") . " append value"); 

try { 
    $tableRestProxy->updateEntity("{table}", $entity); 
} 
catch(ServiceException $e){ 
    $code = $e->getCode(); 
    $error_message = $e->getMessage(); 
    echo $code.": ".$error_message."<br />"; 
} 
相关问题