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':[{ “名称”:“4cf0dadfddfe6”, “属性”:{ “title”:“耳环!”, “file_size”:“135023”, “url”:“http:\ / \ / dtzhqpwfdzscm.cloudfront.net \ /4cf0dadfddfe6.jpg”, “file_name”:“4cf0dadfddfe6.jpg”, “time_stamp”:“1290853092”, “file_type”:“image \ / jpeg”, “content_obj_type”:“上传”, “拇指”:“http:\ / \ / dtzhqpwfdzscm.cloudfront.net \ /4cf0dadfde32b.jpg”, “width”:“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”, “成功”:“真实”, “gibview”:“O”, “avatar_url”:“”, “crop_url”:“” } }], '成功':是的 }
我想按time_stamp排序我该怎么办呢?或者建议学习s3数据库的任何好文章。
答案 0 :(得分:0)
与任何其他sql方言一样 - 可以使用ORDER BY
子句执行排序:
ORDER BY time_stamp
http://docs.amazonwebservices.com/AmazonSimpleDB/latest/DeveloperGuide/index.html?UsingSelect.html
答案 1 :(得分:0)
亚马逊数据库具有空值,因此通过提供time_stamp is not null
条件已解决问题。
答案 2 :(得分:0)
请注意,对于SimpleDB,您只能对WHERE子句中使用的属性进行ORDER BY。这就是为什么
select * from second where gibid = '54' and gibview = 'O' order by time_stamp
不起作用。在WHERE子句中添加“time_stamp is not null”使得time_stamp可用于ORDER BY。