Ninjas are deadly. Chipmunk Ninjas are just weird.
About this blog
Marc Travels
Marc on Twitter
JustLooking on Twitter

Marc Wandschneider is a professional software developer with well over fifteen years of industry experience (yes, he really is that old). He travels the globe working on interesting projects and gives talks at conferences and trade shows whenever possible.

My Publications:

My book, "Core Web Application Programming with PHP and MySQL" is now available everywhere, including

My "PHP and MySQL LiveLessons" DVD Series has just been published by Prentice-Hall, and can be purchased on Amazon, through Informit, or Safari

Apr 28, 2008 | 19:06:28
PHP SimpleDB 0.9.1 - A Parallelizing Client Library for Amazon's SimpleDB Service in PHP5
By marcwan

I am please to announce the release of SimpleDB 0.9.1, yet another SimpleDB client for PHP. It was designed with the following in mind:

  • bulk query and attribute fetching operations
  • bulk upload operations (PutAttributes)
  • fast execution of as many queries as possible
  • proper understandable return values
  • proper and clean exception generation
  • providing command line utilities to view and manipulate SimpleDB Domains, Items, and Attributes.
  • the ability to set domain prefixes for site testing / development

This SimpleDB client requires the following:

  • PHP 5.1.4 or greater (hmac_hash() must be defined)
  • The Curl extension compiled in.

Please consult the README for installation instructions.

You must, of course, be a member of the SimpleDB Beta program to actually be able to use this.

[I’ve rolled out 0.9.2 with a bug fix in it. I’ve actually got a newer version on my hard disk with QueryWithAttributes and sorting support, i just have to finish testing it before uploading]

Comments (13) Add Comment | Tags: php simpledb aws amazon software
Multi-threaded SimpleDB
Posted By: Sebastian Jun 02, 2008 13:27:19

I want to execute multiple GetAttributes in parallel using your library. How could I do so?
Bulk GetAttributes:
Posted By: marcwan Jun 02, 2008 18:16:28
The method you're looking for is "bulkGetAttributes".

$sdb->bulkGetAttributes($domain, array('Item1', 'Item2', ...., 'ItemN'));

You can optionally specify a third parameter saying those attributes whose values you want fetched (instead of -all- of them).

Good Luck!
Data type error line 849?
Posted By: Sebastian Jun 03, 2008 10:34:05
$domain = 'mydomain';
$items = $sdb->query($domain, "['url' != '']");
print_r($items); // prints array( [0] => ['ItemId'] )
$itemattributes = $sdb->bulkGetAttributes($domain, $item);

Results in:

Warning: uksort() [function.uksort]: The argument should be an array in /app/services/SimpleDB.php on line 908
Warning: Invalid argument supplied for foreach() in /app/services/SimpleDB.php on line 1084
Warning: Invalid argument supplied for foreach() in /app/services/SimpleDB.php on line 913
Warning: Invalid argument supplied for foreach() in /app/services/SimpleDB.php on line 1084
Fatal error: Cannot use string offset as an array in /app/services/SimpleDB.php on line 849
Warning: (null)(): 5 is not a valid cURL handle resource in Unknown on line 0
Warning: (null)(): 6 is not a valid cURL handle resource in Unknown on line 0
2 Bugs.
Posted By: marcwan Jun 03, 2008 19:56:42

It looks like there are two bugs here:

1. the code you pasted here should be sending "$items" (with an s) to bulkGetAttributes, not "$item" (no s).

2. my code has a bug where if you give us a 'null', i will generate those errors. I will fix that bug, but in the meantime, if you pass the correct variable, you SHOULD see the correct output.

if that was just a typo in your comment, could you instead describe your data set a little bit and i'll see if i can reproduce the problem.

Posted By: Sebastian Jun 03, 2008 21:40:19
Was a typo, rest is correct. You can see below that the $items variable is not null.

print_r($items); //returns Array ( [0] => Sebastian Stadil )

Notice the lack of quotes around the item.
Issue resolved in new version - Great class
Posted By: Sebastian Jun 12, 2008 15:39:29
I've been using this class for over a week now, and it works very well. I recommend using it for SimpleDB, and use Tarzan-aws for all other Amazon Web Services.

Marc, maybe you would be interested in replacing the SimpleDB class in Tarzan-aws with your own code? See here:
Recent Tarzan improvements
Posted By: Ryan Parman Jul 12, 2008 22:46:51
Sebastian and others: The SimpleDB API from Amazon has long supported PUTTING multiple key-value pairs to an item at once. Tarzan's SimpleDB component has supported this for a while. The same is true for GETTING multiple key-value pairs from a single item. It does not yet have a dedicated method for assigning key-value pairs to multiple items/domains at once. Alternatively, most "core" Tarzan methods have an optional parameter that exposes the cURL handle for the request that can be added to a curl_multi_exec() request. Tarzan also has an optional parameter on the query() method that will fetch the results of that query, all using the cURL/MultiCURL-based TarzanHTTPRequest class.

I'm not saying one is better than the other -- both classes appear to share a similar philosophy. I just happen to be the developer of Tarzan, so I'm a bit biased. That and I want Tarzan to be able to grow beyond myself. If you've been interested in Tarzan, but haven't looked lately, take another look.
Bug fix
Posted By: marcwan Feb 08, 2009 18:03:28
Yah, that's it, although I fixed that a while ago. Apparently, however, in my old age, I completely neglected to roll out the fixed version to the server.

Apologies!! 0.9.2 rolled out.

404 Error
Posted By: Tim Feb 11, 2009 11:11:10
Download link gives me a 404 Error. How do I get the src?
Posted By: marcwan Feb 11, 2009 17:33:14

I used .gz, and not .bz2. Fixed! Sorry for the troubles.
Add a Comment





Copyright © 2005-2008 Marc Wandschneider All Rights Reserved.