как я могу дать заказ в базе данных s3 - PullRequest
0 голосов
/ 30 ноября 2010
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 "," 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}

Я хочу отсортировать по time_stamp, как я могу это сделать.?или любую хорошую статью для изучения базы данных s3, пожалуйста, предложите.

Ответы [ 3 ]

0 голосов
/ 18 декабря 2010

Amazon db имеет нулевые значения, поэтому условие time_stamp is not null решило проблему.

0 голосов
/ 27 января 2011

Обратите внимание, что с 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.

0 голосов
/ 30 ноября 2010

Как и в любом другом SQL-диалекте - сортировку можно выполнить с помощью ORDER BY условия:

ORDER BY time_stamp

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

...