0
if(!$_GET){
    echo "{'success':false, 'error':'No query parameters submitted'}";
    return;
}

// 1. Include the SimpleDB class if it does not exist
if (!class_exists('SimpleDB'))require_once('sdb.php');  

// 2. Set awsAccessKey and awsSecretKey to your values
require_once('config.inc.php');  

// create connection
$sdb = new SimpleDB(awsAccessKey, awsSecretKey);  
$condition = "";
$status = "";

//$params = json_decode(stripslashes($_POST['hash']));
$params = $_GET;
foreach($params as $key => $value){
    $condition .= " " . $key . " = '" . $value . "' and" ;      
}

$condition = preg_replace('/and$/', "", $condition);

$query = "select * from $domain";

if($condition!= " _empty_ = '' "){
    $query .= " where $condition ";
}

$fileHash = '{';
if($files = $sdb->select($domain, $query)){
    $status = 'true';
    $fileHash .= "'files' : ".json_encode($files).", ";
}else{
    $status = 'false';
    $fileHash .= "'files' : [], ";
    $fileHash .= "'error' : 'No records retrieved from SimpleDB ".json_encode($sdb->ErrorCode)."', ";
}
$fileHash .= "'success':".$status."}";
echo $fileHash;

我的 json 回复 { 'files': [{ "Name": "4cf0dadfddfe6", "Attributes": { "title": "Earrings!", "file_size": "135023", "url": "http:\/\/dtzhqpwfdzscm. cloudfront.net\/4cf0dadfddfe6.jpg", "file_name": "4cf0dadfddfe6.jpg", "time_stamp": "1290853092", "file_type": "image\/jpeg", "content_obj_type": "upload", "thumb" :“http:\/\/dtzhqpwfdzscm.cloudfront.net\/4cf0dadfde32b.jpg”,“宽度”:“176.04166666666669”,“高度”:“171”,“userid”:“4”,“gibid”:“54”,“contentid”:“4cf0dadfddfe6”,“qqfile”:“il_570xN.182320055.jpg”,“original_name”:“il_570xN.182320055.jpg”,“y ":"72","x":"535","on_floor":"false","success":"true","gibview":"O","avatar_url":"","crop_url":" " } }], '成功': true }contentid”:“4cf0ddfddfe6”,“qqfile”:“il_570xN.182320055.jpg”,“original_name”:“il_570xN.182320055.jpg”,“y”:“72”,“x”:“535”,“on_floor” :“假”,“成功”:“真”,“gibview”:“O”,“avatar_url”:“”,“crop_url”:“”}}],“成功”:真}contentid”:“4cf0ddfddfe6”,“qqfile”:“il_570xN.182320055.jpg”,“original_name”:“il_570xN.182320055.jpg”,“y”:“72”,“x”:“535”,“on_floor” :“假”,“成功”:“真”,“gibview”:“O”,“avatar_url”:“”,“crop_url”:“”}}],“成功”:真}“x”:“535”,“on_floor”:“false”,“成功”:“true”,“gibview”:“O”,“avatar_url”:“”,“crop_url”:“”}}],'成功':真}“x”:“535”,“on_floor”:“false”,“成功”:“true”,“gibview”:“O”,“avatar_url”:“”,“crop_url”:“”}}],'成功':真}

我想按 time_stamp 排序我该怎么做。?或任何学习s3数据库的好文章请建议。

4

3 回答 3

0

Amazon db 具有空值,因此通过提供time_stamp is not null条件解决了问题。

于 2010-12-18T04:54:56.187 回答
0

请注意,对于 SimpleDB,您只能 ORDER BY 您在 WHERE 子句中使用的属性。这就是为什么

select * from second where gibid = '54' and gibview = 'O' order by time_stamp

不起作用。将“time_stamp is not null”添加到 WHERE 子句使 time_stamp 可用于 ORDER BY。

于 2011-01-27T12:06:51.007 回答
0

就像在任何其他 sql 方言中一样 - 可以使用ORDER BY子句执行排序:

ORDER BY time_stamp

http://docs.amazonwebservices.com/AmazonSimpleDB/latest/DeveloperGuide/index.html?UsingSelect.html

于 2010-11-30T07:18:01.153 回答