PHPExample usage: Download S3QLgoodies.php (at the bottom of this page) and under the same directory, create a script: example.phpInside example.php add the following lines:
example.php<?php
include_once('S3QLgoodies.php'); $s3ql = array('url'=>'http://ibl.mdanderson.org/s3dbdemo3','key'=>'6OhmdK6M5KNVScq','select'=>'*','from'=>'projects','format'=>'php'); list($url, $data) = S3DBcall($s3ql); echo '<pre>';print_r($data);
?>
You can now refer to you s3db project (to build new queries, for example) by their indexes in the array:
$s3ql = array('url'=>'http://ibl.mdanderson.org/s3dbdemo3','key'=>'6OhmdK6M5KNVScq','select'=>'*','from'=>'rules','where'=>array('project_id'=>$data[0]['project_id']),'format'=>'php');
list($url,$rules) = S3DBcall($s3ql);
echo '<pre>';print_r($rules);echo '</pre>';
The library also includes uploading and inserting files on s3db
move2s3db<?php
include_once('S3QLgoodies.php'); #Specify the path to the file you wish to upload $file ='/home/mhdeus/.public_html/welkinRDF.png';
#specify the Url and Key where you want your file to be uploaded, along with an item_id and a rule_id from your deployment $url='http://ibl.mdanderson.org/s3dbdemo3'; $key='6OhmdK6M5KNVScq'; $rule_id='12140'; $item_id='12141';
#In case you want to know how much time the upload took $time=date('His');
$results=move2s3db($file, $url,$key,$rule_id,$item_id); if($results[0]['error_code']=='0') { echo "File ".basename($file)." was uploaded in ".(date('His')-$time)." seconds"; echo '<br />You can see what you\'ve uploaded by using the link: <a href="'.$url.'/item.php?item_id='.$item_id.'&key='.$key.'">http://ibl.mdanderson.org/s3dbdemo3/item.php?item_id='.$item_id.'&key='.$key.'</a>';
} else { echo $results[0]['message']; }
?>
JavascriptDownload s3ql_js.txtDownload jsonpp_js.txt from JSON, JSONP, JSONPP? and in the same directory create a script: example.html
example.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript" src="jsonpp_js.txt"></script> <script type="text/javascript" src="s3ql_js.txt"></script> <script type="text/javascript"> var s3ql = new Array; s3ql['url']='http://ibl.mdanderson.org/s3dbdemo3'; s3ql['key'] = '6OhmdK6M5KNVScq'; s3ql['select'] = '*'; s3ql['from'] = 'projects'; s3ql['format'] = 'json'; var url = S3QLquery(s3ql); window.open(url); </script> </head>
<body> </body> </html>
See JSON, JSONPP, JSONPPP library for examples on handling JSON variables and JSONP callbacks. MatlabUsage example: Download S3QLSyntax.m, html2cell.m and s3db_read.m (at the bottom of this page) and create a new script in the same directory ( example.m)
example.ms3ql = struct('url','http://ibl.mdanderson.org/s3dbdemo3', 'key','6OhmdK6M5KNVScq', 'select', '*','from','projects','format','html')
url = S3QLSyntax(s3ql);
data = html2cell(urlread(url));
data = cell2struct(data(2:end,:), data(1,:), 2)
%You can now call you projects using their index
s3ql = struct('url','http://ibl.mdanderson.org/s3dbdemo3', 'key','6OhmdK6M5KNVScq', 'select', '*','from','rules', ... 'where',struct('project_id', data(1).project_id),... 'format','html')
rules = html2cell(urlread(S3QLSyntax(s3ql)))
rules = cell2struct(rules(2:end,:), rules(1,:), 2)
%As an alternative, s3db_read.m performs these steps for you: s3ql = struct('url','http://ibl.mdanderson.org/s3dbdemo3', 'key','6OhmdK6M5KNVScq', 'select', '*','from','projects','format','html')
projects = s3db_read(s3ql)
You may also want to use matlab to upload large file into S3DB, for that purpose download the function move2s3db.m and base64encode.m (in case your version of Matlab does not have it yet)
move2s3db.mCreate a structure with fields:
url key item_id rule_id file
Item_id and Rule_id correspond to the ids of the statement where you want to insert your file
Run the function: x = struct('url','http://ibl.mdanderson.org/s3dbdemo3','key','6OhmdK6M5KNVScq','item_id','12551','rule_id','2080','file','test.CEL')
[rep,url,filekey] = move2s3db(x)
|
Subpages (1):
PHP functions
Attachments (9)
-
S3QLSyntax.m - on Aug 13, 2008 12:21 PM by Lena Deus (version 1)
2k
Download
-
S3QLgoodies.php - on Aug 27, 2008 7:34 PM by Lena Deus (version 4 / earlier versions)
5k
Download
-
base64encode.m - on Sep 24, 2008 10:44 AM by Lena Deus (version 1)
5k
Download
-
example.m - on Aug 13, 2008 12:33 PM by Lena Deus (version 1)
1k
Download
-
example.php - on Aug 13, 2008 12:34 PM by Lena Deus (version 1)
1k
Download
-
html2cell.m - on Aug 13, 2008 12:21 PM by Lena Deus (version 1)
1k
Download
-
move2s3db.m - on Sep 24, 2008 10:40 AM by Lena Deus (version 3 / earlier versions)
4k
Download
-
s3db_read.m - on Aug 13, 2008 12:32 PM by Lena Deus (version 1)
1k
Download
-
s3ql_js.txt - on Sep 4, 2008 2:50 PM by Lena Deus (version 2 / earlier versions)
2k
Download
|