Sono in grado di interrogare le mie tabelle dynamodb, ma voglio solo recuperare il valore attuale. Non voglio l'output di formattazione. Questa stessa domanda è stato risposto qui per Java, ma sto cercando la soluzione PHP: Retrieving just the item value from a dynamodb table?dynamodb getitem using php - Voglio solo recuperare il valore
Ecco la mia domanda getitem:
$response = $dynamodb->getItem(array(
"TableName" => $tableName,
"ConsistentRead" => true,
"Key" => array(
"userguid" => array(Type::STRING => $userguid)
),
"AttributesToGet" => array("token")
));
print_r($response["Item"]["token"]);
Ecco l'output:
Array
(
[S] => 9d194513
)
Tutto quello che voglio tornare è:
9d194513
Ho assunto il la risposta logica sarebbe quella di modificare l'ultima riga in:
print_r($response["Item"]["token"]["S"]);
Ma poi il mio codice non restituisce nulla. Ovviamente sto ancora imparando PHP qui e ogni aiuto sarebbe apprezzato.
'var_dump ($ response);' puoi pubblicare ciò che stampa? – Fabio
un semplice vecchio 'var_dump ($ response);' restituisce 8098 linee. Supponevo che stavate cercando l'output di 'var_dump ($ response [" Item "] [" token "]);'. Questo restituisce: 'array (1) { [" S "] => string (8)" 9d194513 " } ' – user2463882
Sì ho visto sulla domanda, prova con 'echo $ response [" Item "] [" token "] [" S "];' o 'print ($ response [" Item "] [" token "] [" S "]);' poichè non è un array – Fabio