Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting data from SimpleDB using PHP
    primarykey
    data
    text
    <p>How do I get data out of SimpleDB? All I wanted to do was put data in and then get data out. It looks like the data is not easy to get out and in the end will require computing power to extract by looping etc. Am I correct?</p> <p>Here is my code to extract the data:</p> <pre><code>&lt;?php // Include the SDK require_once 'sdk.class.php'; // Instantiate $sdb = new AmazonSDB(); $select_expression = 'SELECT * FROM ' . $domain_name; $next_token = null; do { if ($next_token) { $response = $sdb-&gt;select($select_expression, array( 'NextToken' =&gt; $next_token, )); } else { $response = $sdb-&gt;select($select_expression); } // Get Data for row $body = $response-&gt;body-&gt;to_array()-&gt;getArrayCopy(); echo "ID: " . $msgId . "&lt;br&gt;"; $next_token = isset($response-&gt;body-&gt;SelectResult-&gt;NextToken) ? (string) $response-&gt;body-&gt;SelectResult-&gt;NextToken : null; } while ($next_token); echo "&lt;br&gt;"; ?&gt; </code></pre> <p>Here is the extract of the data I'm trying to extract.</p> <pre><code>Array ( [@attributes] =&gt; Array ( [ns] =&gt; http://sdb.amazonaws.com/doc/2009-04-15/ ) [SelectResult] =&gt; Array ( [Item] =&gt; Array ( [0] =&gt; Array ( [Name] =&gt; 1 [Attribute] =&gt; Array ( [0] =&gt; Array ( [Name] =&gt; msgAddress [Value] =&gt; +2782555555 ) [1] =&gt; Array ( [Name] =&gt; msgType [Value] =&gt; S ) [2] =&gt; Array ( [Name] =&gt; msgSubmitDate [Value] =&gt; 2012-09-02 15:48:46 ) [3] =&gt; Array ( [Name] =&gt; msgText [Value] =&gt; Test SMS message for ID no 1 ) ) ) [1] =&gt; Array ( [Name] =&gt; 2 [Attribute] =&gt; Array ( [0] =&gt; Array ( [Name] =&gt; msgAddress [Value] =&gt; +27825555555 ) [1] =&gt; Array ( [Name] =&gt; msgType [Value] =&gt; P ) [2] =&gt; Array ( [Name] =&gt; msgSubmitDate [Value] =&gt; 2012-09-02 15:48:46 ) [3] =&gt; Array ( [Name] =&gt; msgText [Value] =&gt; Test phone message for ID no 2 ) ) ) [2] =&gt; Array ( [Name] =&gt; 3 [Attribute] =&gt; Array ( [0] =&gt; Array ( [Name] =&gt; msgAddress [Value] =&gt; name@domain.co.za ) [1] =&gt; Array ( [Name] =&gt; msgType [Value] =&gt; E ) [2] =&gt; Array ( [Name] =&gt; msgSubmitDate [Value] =&gt; 2012-09-02 15:48:46 ) [3] =&gt; Array ( [Name] =&gt; msgText [Value] =&gt; Test email message for ID no 3 to name@domain.co.za ) ) ) [3] =&gt; Array ( [Name] =&gt; 4 [Attribute] =&gt; Array ( [0] =&gt; Array ( [Name] =&gt; msgAddress [Value] =&gt; andrebruton ) [1] =&gt; Array ( [Name] =&gt; msgType [Value] =&gt; P ) [2] =&gt; Array ( [Name] =&gt; msgSubmitDate [Value] =&gt; 2012-09-02 15:48:46 ) [3] =&gt; Array ( [Name] =&gt; msgText [Value] =&gt; Test push notification message for ID no 4 ) ) ) ) ) ) </code></pre> <p>All I want to get is the following variables:</p> <p>msgId (the Name), msgType, msgAddress, msgText, msgSubmitDate</p> <p>If I can get it using $msgType = Body->SelectResult->Item->Name or something like that.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload