title: DynamoDB PHP getItem() - How to tell if item does not exist
body: <p>I am writing a "Get or Create" method that attempts to get an item, but if it doesn't exist, it will create a fresh new version of it. Obviously, I want to know for certain that the item didn't exist when I attempted to get it, so that it never overwrites existing data.</p>
  
  <p>Am I correct in assuming <code>$result["Item"] === null</code> <strong>if and only if</strong> the item did not exist in the database at the time of the request? That is, if the item existed prior to the request, will this condition always evaluate to false, regardless of API errors, etc.? Or is there something else I should check for instead?</p>
  
  <pre><code>    $result = $this-&gt;client-&gt;getItem(
          array(
              "TableName" =&gt; $tableName,
              "Key" =&gt; array(
                  $keyName =&gt; array(Type::STRING =&gt; $key),
              )
          )
      );
  
      if ( $result["Item"] === null )
      {
          //Item does not exist; create it and write it to dynamoDb (code not shown)
      }
  
      return $result["Item"];
  </code></pre>