Php (1) azure表存储上的筛选器和(2)捕获错误

Php (1) azure表存储上的筛选器和(2)捕获错误,php,azure,azure-table-storage,Php,Azure,Azure Table Storage,我有一个azure表存储,其中包含一些实体。放置新实体没有问题。更新现有实体也没有问题,这一切都很好 以下代码挂起在该行:result=$tableClient->retrieveEntities('users','Name eq'John Doe','partition1')(在底部的某个地方)它给出一个http 500错误 require_once("Microsoft/WindowsAzure/Storage/Table.php"); require_once("Microsoft/Win

我有一个azure表存储,其中包含一些实体。放置新实体没有问题。更新现有实体也没有问题,这一切都很好

以下代码挂起在该行:
result=$tableClient->retrieveEntities('users','Name eq'John Doe','partition1')(在底部的某个地方)它给出一个http 500错误

require_once("Microsoft/WindowsAzure/Storage/Table.php");
require_once("Microsoft/WindowsAzure/Storage/DynamicTableEntity.php");

$accountName = '***';
$accountKey = '*****';
$tableClient = new Microsoft_WindowsAzure_Storage_Table('table.core.windows.net',$accountName,$accountKey); 
$tableClient->createTableIfNotExists('users');

$result = $tableClient->listTables();
foreach ($result as $table){
    echo 'Table name is: ' . $table->Name . "\r\n<br />";
}
function setUser($accountName,$accountKey,$partitionName,$data) {
    $tableClient = new Microsoft_WindowsAzure_Storage_Table('table.core.windows.net',$accountName,$accountKey);
    $update = false;
    if(isset($data['ID']) && $entity = $tableClient->retrieveEntityById('users',$partitionName,$data['ID'])){
        $update = true;
        unset($data['ID']);
    } else {
        $guid = substr(com_create_guid(),1,32);
        $entity = new Microsoft_WindowsAzure_Storage_DynamicTableEntity($partitionName, $guid);
        $entity->ID = $guid;
    }

    $keys = array_keys($data);
    foreach($keys as $key){
        $entity->$key = $data[$key];
    }       
    if($update){
        $tableClient->updateEntity('users',$entity,true);
    } else {
        $tableClient->insertEntity('users',$entity);
    }
}   
setUser($accountName,$accountKey,'partition1',array(Name => 'John Doe',Email => 'johndoe@gmail.com',Time => time()));



$result = $tableClient->retrieveEntities('users',"Name eq 'John Doe'",'partition1');
//$result = $tableClient->retrieveEntities('users');




foreach($result as $data) {
    echo $data->ID;
    echo ' - ';
    echo $data->Name;
    echo ' - ';
    echo $data->Email;
    echo ' - ';
    echo $data->Time;
    echo '<br />';
}
只是随便猜测一下(所以我可能错了)-我在这里查看了检索实体的代码:(希望我看的是正确的位置),并注意到您正在将
partition1
作为参数之一传递给该方法

这会导致问题吗?尝试以下方法:

$tableClient->retrieveEntities('users',"PartitionKey eq 'partition1' and Name eq 'John Doe'") 

我还查看了CodePlex()上的项目页面,其中提到该项目已被弃用,取而代之的是Github()上的Azure SDK。恕我直言,在移植应用程序以使用新SDK方面投入一些时间可能是值得的。只是想一想。

有点不相关的评论,但是你不使用微软的官方PHP SDK有什么特别的原因吗:?我使用的是微软的官方PHP SDK,但我认为它是旧版本?我以前把它用在普通的blob存储中,在那时它工作得很好。我可以试试你指的SDK,谁知道这解决了我的问题,但我又回到了0。如果有人看到我做错了什么,那就好了。随便猜一猜(所以我可能错了)-我在这里查看了检索实体的代码:(希望我看的是正确的位置),并注意到您正在将
partition1
作为参数之一传递给该方法。这可能是造成问题的原因。尝试类似于
$tableClient->retrieveEntities('users',“PartitionKey eq'partition1'和Name eq'John Doe')
的方法,看看这是否解决了问题。谢谢,这就解决了筛选问题!分区显然不是“retrieveEntities”方法的参数。如果没有结果,我什么也没有得到,因此如果计数(数组)为0,则请求的实体不存在。不再需要试抓了@瓜拉夫曼特里。你能把你的评论贴出来作为答案吗?这样我就可以把它标记为“已解决”。非常感谢。
$tableClient->retrieveEntities('users',"PartitionKey eq 'partition1' and Name eq 'John Doe'")