2
votes

I have a dynamodb table with uid for the hash key and Score for the range key and I am trying to get an element to return. Unfortunately after going through all of the online documentation I could find I am still getting the same error:

AWS Error Message: Either the KeyConditions or KeyConditionExpression parameter must be specified in the request.

$result = $this->client->query(array(
    'TableName' => 'Leaderboard',
    'KeyConditionExpression' => 'uid = :u_id and Score >= :u_score',
    'ExpressionAttributeValues' =>  array (
        ':u_id' => array('S' => 'test'),
        ':u_score' => array('S' => '100')
    ),
    'ConsistentRead' => true
));

print_r($result['Items']);

'KeyConditionExpression' is obviously included within the query parameters. I also tried 'N' => '100' which makes more sense but that did not fix the error which is seemingly unrelated.

1
Can you check if your php-sdk is up to date..Harshal Bulsara
Thank you that seemed to fix the previous issue :)Austin Oblouk

1 Answers

0
votes
  • Query Item

    $response = $client->query(array(
        'TableName' => '[Table_Name]',
        'KeyConditionExpression' => '[Hash_Name] = :v_hash and [Range_Name] = :v_range',
        'ExpressionAttributeValues' =>  array (
            ':v_hash'  => array('S' => '[Hash_Value]'),
            ':v_range' => array('S' => '[Range_Value]')
        )
    ));
    
    echo $response;
    


Hope this helps