2017-01-25 10 views
2

DynamoidbでCodeigniter 3でクエリを作成するには、どのようにインデックスを追加するのですか?私の例ではcodeigniter 3とdynamodbを使用したクエリ

私は次のエラーを取得する:

1 validation error detected: Value null at 'hashKeyValue' failed to satisfy constraint: Member must not be null

は、これは私の例です:あなたはこのエラーを取得している

function obtener($fecha_registro) { 

    $client = new AmazonDynamoDB(); 
    $response = $client->query(array(

    'TableName' => 'nom_table', 
    'KeyConditionExpression' => 'id_registro = :v_hash and fecha_registro = :v_range', 
    'ExpressionAttributeValues' => array (
     ':v_hash' => array('S' => '148537355319'), 
     ':v_range' => array('S' => $fecha_registro) 
    ) 
)); 


    print_r($response); 
     if ($response->status == '200'){ 
      return $response->body->Items; 
     } else {  
      print_r($response); 
     } 
} 
+0

[[関連項目fを取得できません] ROMのDynamoDBコアデータを使用して](http://stackoverflow.com/questions/14381937/unable-to-fetch-related-item-from-dynamodb-using-core-data) – LuFFy

答えて

0

唯一の理由は次のとおりです。

Amazon DynamoDB is not handling empty or null attributes.

として、 DynamoDB Documentation

Attribute values cannot be null.

同じ問題はAWS Developer Forumでも発生します。 obtener()に機能するためにあなたの変数$fecha_registroを渡す前に

、 あなたが渡された変数は、同じようにあなたの関数を呼び出す前に、チェックを追加するには、シナリオのNon EmptyまたはNot Null

であるかどうかを確認する必要があります。

ソリューション以下:

if(isset($fecha_registro) && ($fecha_registro != '' || $fecha_registro != NULL)){ 
    obtener($fecha_registro); 
} 
+1

Haaa okありがとう友だち – Dave

+0

@Dave、あなたはあなたの質問が解決されたことを知ったら、アップアップして回答を受け入れる習慣を保つべきです。 :) – LuFFy

関連する問題