开发者

how can i give the order by in s3 database

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 a开发者_StackOverflow中文版nd 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;

my json response { '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", "width": "176.04166666666669", "height": "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": "" } }], 'success': true }

i want to sort by time_stamp how can i do this .? or any good article for learning s3 database please suggest.


Note that with SimpleDB you can only ORDER BY an attribute that you used in the WHERE clause. That's why

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

doesn't work. Adding "time_stamp is not null" to the WHERE clause makes time_stamp available for ORDER BY.


Like in any other sql dialect - sorting can be performed with ORDER BY clause:

ORDER BY time_stamp

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


Amazon db has null values so by giving time_stamp is not null condition have solved the problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜