示例#1
0
 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);
 }
示例#2
0
<?php

require_once '/usr/share/php/AWSSDKforPHP/sdk.class.php';
define('AWS_KEY', 'AKIAIGKECZXA7AEIJLMQ');
define('AWS_SECRET_KEY', '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');
define('AWS_ACCOUNT_ID', '457964863276');
# construct the message (use zero padding to handle
# simpledb's lexicographic ordering)
$account = array('fair' => 'yes', 'PDFs' => sprintf('%05d', '0'));
$sdb = new AmazonSDB();
# $sdb->set_region($sdb::REGION_EU_W1);
$accounts = $sdb->create_domain('accounts');
$accounts->isOK() or die('could not create domain accounts');
$response = $sdb->put_attributes('accounts', '*****@*****.**', $account, true);
pr($response->body);
function pr($var)
{
    print '<pre>';
    print_r($var);
    print '</pre>';
}
 *	Create needed BOOK_AWS_USAGE_DOMAIN SimpleDB domain.
 *
 * Copyright 2009-2010 Amazon.com, Inc. or its affiliates. All Rights
 * Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"). You
 * may not use this file except in compliance with the License. A copy
 * of the License is located at
 *
 *       http://aws.amazon.com/apache2.0/
 *
 * or in the "license.txt" file accompanying this file. This file is
 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
 * OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the
 * License.
 */
error_reporting(E_ALL);
require_once 'cloudfusion.class.php';
require_once 'include/book.inc.php';
$domain = BOOK_SNAP_LOG_DOMAIN;
// Create the SimpleDB access object
$sdb = new AmazonSDB();
// Create the SimpleDB domain
$res = $sdb->create_domain($domain);
// Check result
if (!$res->isOK()) {
    exit("Create domain operation failed for domain {$domain}\n");
}
print "Domain {$domain} created.\n";
exit(0);
/*%******************************************************************************************%*/
// SETUP
// Enable full-blown error reporting. http://twitter.com/rasmus/status/7448448829
error_reporting(-1);
// 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();