protected function setUp() { $this->object = new \AmazonSDB(); $this->object->set_response_class('\\ORM\\SDB\\SDBResponse'); $this->object->set_region(\AmazonSDB::REGION_APAC_SE1); $this->object->create_domain(self::DOMAIN); $this->object->batch_put_attributes(self::DOMAIN, $this->_testItems); }
// Set HTML headers header("Content-type: text/html; charset=utf-8"); // Include the SDK require_once '../sdk.class.php'; /*%******************************************************************************************%*/ // ADD DATA TO SIMPLEDB // Instantiate the AmazonSDB class $sdb = new AmazonSDB(); // Store the name of the domain $domain = 'php-sdk-getting-started'; // Create the domain $new_domain = $sdb->create_domain($domain); // Was the domain created successfully? if ($new_domain->isOK()) { // Add a batch of item-key-values to your domain $add_attributes = $sdb->batch_put_attributes($domain, array('Item_01' => array('Category' => 'Clothes', 'Subcategory' => 'Sweater', 'Name' => 'Cathair Sweater', 'Color' => 'Siamese', 'Size' => array('Small', 'Medium', 'Large')), 'Item_02' => array('Category' => 'Clothes', 'Subcategory' => 'Pants', 'Name' => 'Designer Jeans', 'Color' => 'Paisley Acid Wash', 'Size' => array('30x32', '32x32', '32x34')), 'Item_03' => array('Category' => 'Clothes', 'Subcategory' => 'Pants', 'Name' => 'Sweatpants', 'Color' => array('Blue', 'Yellow', 'Pink'), 'Size' => 'Large', 'Year' => array('2006', '2007')), 'Item_04' => array('Category' => 'Car Parts', 'Subcategory' => 'Engine', 'Name' => 'Turbos', 'Make' => 'Audi', 'Model' => 'S4', 'Year' => array('2000', '2001', '2002')), 'Item_05' => array('Category' => 'Car Parts', 'Subcategory' => 'Emissions', 'Name' => 'O2 Sensor', 'Make' => 'Audi', 'Model' => 'S4', 'Year' => array('2000', '2001', '2002')))); // Were the attributes added successfully? if ($add_attributes->isOK()) { // Add an additional size to Item_01 $append_attributes = $sdb->put_attributes($domain, 'Item_01', array('Size' => 'Extra Large')); // Were the new attributes appended successfully? if ($append_attributes->isOK()) { // Use a SELECT expression to query the data. // Notice the use of backticks around the domain name. $results = $sdb->select("SELECT * FROM `{$domain}` WHERE Category = 'Clothes'"); // Get all of the <Item> nodes in the response $items = $results->body->Item(); // Re-structure the data so access is easier (see helper function below) $data = reorganize_data($items); // Generate <table> HTML from the data (see helper function below) $html = generate_html_table($data);