Print This Post

SimpleDB PHP Sample Program

Amazon Web Services

While learning to use the Amazon SimpleDB services I looked for a sample PHP program. I could not get the one Amazon provides to work. Dan Myers’ wrote a SimpleDB PHP class but there was no sample code to use it.

This is a collection of small programs that use Dan Myers’ SimpleDB PHP class.

This is a very simple set of examples of working with the Amazon SimpleDB. It is written on top of Don Myers’ SimpleDB PHP class.

Download V1.0 July 28, 2009

Rich Helms

Uses Amazon SimpleDB PHP Class by heronblademastr

* listdomains [list all domains]
* createrecord (single) and domain tag [check if the “tag” domain exists and if not create, then create a record]
* getrecord (single) in domain tag [list that specific record]
* deleterecord (single) in domain tag [delete that specific record]
* createrecords and domain tag [bulk load records]
* listrecords in tag [list all records in tag domain]
* deletedomain tag [delete tag domain]

To install, configure with your awsAccessKey and awsSecretKey.
Copy to the host. Run index.php

Note: An important concept with SimpleDB is Eventually Consistent. This means when you update, add or delete a record you will not see it immediately. This is why the programs are broken into small programs, to give the system time to reflect the updates.

For details see:



  1. Dan Myers  •  Jul 28, 2009 @12:44 pm

    Awesome, Rich. I hope you don’t mind if I link people to this :)

  2. RichHelms  •  Jul 28, 2009 @12:52 pm

    Please do. I love the class you wrote. I fixed the bug in the deleteattributes that I posted on your site. I also added some comments to help explain the class.

  3. ben  •  Aug 9, 2009 @7:51 pm

    thanks. just what i was looking for.

  4. Charles G.  •  Jan 21, 2010 @9:19 am

    Thanks for your work, the php libraries provided by the amazon team are not “simple” at all. Both of you did a great job.

  5. karlo k  •  Jan 29, 2010 @1:54 pm

    This is fantastic stuff, and immensely appreciated! I am having a huge time wrapping my head around SimpleDB and trying to not be too dense in the process. The simplicity and clarity of both php-sdb and the sample code you’ve created has helped tremendously. However, (and I hope this is something my sleep-deprived brain is just missing), I keep getting an auth error: “Warning: SimpleDB::listDomains(): AuthFailure: AWS was not able to validate the provided access credentials in /home2/pixelbo1/public_html/rp/_test/sdb/sdb.php on line 672”. I’ve double checked my auth codes and verified that they are, in fact, in the on my server, but alas, error. Any thoughts, hints, shoves in the correct direction would be appreciated! Thanks!

  6. Rich Helms  •  Jan 29, 2010 @2:41 pm


    Do you have curl enabled on your server? The API uses curl to do the communications.

  • Archives

  • Meta