$row=$this->db->fetchAll("select count(*) from reference where id in (select refid from mdref where uuid in (select uuid from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80'))");
$sql="select * from reference where id in (select refid from mdref where uuid in (select uuid from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80')) order by reference limit ? offset ?";
$state=$this->db->query("select count(*) from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' and id in (select id from keyword where keytype='theme' and (keyword='冰川' or keyword='沙漠' or keyword='地貌' or keyword='植被' or keyword='草场' or keyword='沙漠化' or keyword='基础地理' or keyword='遥感影像' or keyword='水文地质' or keyword='社会经济' or keyword='人口' or keyword='SWAT' or keyword='NPP' or keyword='WRF' or keyword='辐射' or keyword='NEP'))");
$row=$state->fetchAll();
$sum=$row[0]['count'];
$sql="select uuid,title from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' and id in (select id from keyword where keytype='theme' and (keyword='冰川' or keyword='沙漠' or keyword='地貌' or keyword='植被' or keyword='草场' or keyword='沙漠化' or keyword='基础地理' or keyword='遥感影像' or keyword='水文地质' or keyword='社会经济' or keyword='人口' or keyword='SWAT' or keyword='NPP' or keyword='WRF' or keyword='辐射' or keyword='NEP')) order by timebegin,title limit ? offset ?";
$state=$this->db->query("select count(*) from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' and id in (select id from keyword where keytype='theme' and (keyword='DEM' or keyword='土地利用' or keyword='土壤' or keyword='气象' or keyword='水文观测' or keyword='灌溉' or keyword='试验'))");
$row=$state->fetchAll();
$sum=$row[0]['count'];
$sql="select uuid,title from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' and id in (select id from keyword where keytype='theme' and (keyword='DEM' or keyword='土地利用' or keyword='土壤' or keyword='气象' or keyword='水文观测' or keyword='灌溉' or keyword='试验')) order by timebegin,title limit ? offset ?";
$state=$this->db->query("select count(*) from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' and id in (select id from keyword where keytype='theme' and (keyword='WRF' or keyword='NPP' or keyword='SWAT' or keyword='NEP' or keyword='辐射'))");
$row=$state->fetchAll();
$sum=$row[0]['count'];
$sql="select uuid,title from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' and id in (select id from keyword where keytype='theme' and (keyword='WRF' or keyword='NPP' or keyword='SWAT' or keyword='NEP' or keyword='辐射')) order by timebegin,title limit ? offset ?";
$state=$this->db->query("select count(*) from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' and id in (select id from keyword where keytype='theme' and (keyword='人口' or keyword='社会经济'))");
$row=$state->fetchAll();
$sum=$row[0]['count'];
$sql="select uuid,title from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' and id in (select id from keyword where keytype='theme' and (keyword='人口' or keyword='社会经济')) order by timebegin,title limit ? offset ?";
$state=$this->db->query("select count(*) from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' and id in (select id from keyword where keytype='theme' and (keyword='冰川' or keyword='沙漠' or keyword='地貌' or keyword='植被' or keyword='草场' or keyword='沙漠化'))");
$row=$state->fetchAll();
$sum=$row[0]['count'];
$sql="select uuid,title from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' and id in (select id from keyword where keytype='theme' and (keyword='冰川' or keyword='沙漠' or keyword='地貌' or keyword='植被' or keyword='草场' or keyword='沙漠化')) order by timebegin,title limit ? offset ?";
$sql="select uuid,title from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' order by timebegin,title";
$this->view->metadata=$this->db->fetchAll($sql);
}
functiontagAction()
{
$key=$this->_request->getParam('key');
$page=(int)$this->_request->getParam('page');
if(empty($page))$page=1;
$offset=$this->limit*($page-1);
if(!empty($key)){
$this->view->codename=$key;
$sql=$this->db->quoteInto('select count(id) from keyword where keyword=?',$key);
$state=$this->db->query($sql);
$row=$state->fetchAll();
$sum=$row[0]['count'];
$sql="select uuid,title,id,description from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' and id in (select id from keyword where keyword='".$key."') order by timebegin,title limit ? offset ?";
$state=$this->db->query("select keyword.keyword,count(*) from keyword left join metadata on keyword.id=metadata.id where keyword.keytype='place' and metadata.source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' group by keyword.keyword order by count desc");
$k1=$state->fetchAll();
$state=$this->db->query("select k.keyword,count(k.keyword) from keyword k left join metadata m on k.id=m.id where k.keytype='theme' and m.source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' group by k.keyword order by k.keyword");
$k2=$state->fetchAll();
$state=$this->db->query("select k.keyword,count(k.keyword) from keyword k left join metadata m on k.id=m.id where k.keytype='discipline' and m.source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' group by k.keyword order by k.keyword");
$k3=$state->fetchAll();
$state=$this->db->query("select k.keyword,count(k.keyword) from keyword k left join metadata m on k.id=m.id where k.keytype='stratum' and m.source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' group by k.keyword order by k.keyword");
$k4=$state->fetchAll();
$state=$this->db->query("select keyword.keyword,count(*) from keyword left join metadata on keyword.id=metadata.id where keyword.keytype='temporal' and metadata.source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' group by keyword.keyword order by keyword.keyword");
$row=$this->db->fetchAll("select count(*) from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' and ".$where);
$sum=$row[0]['count'];
$sql="select uuid,title,id,description from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' and ".$where." order by timebegin,title limit ? offset ?";
$sql="select id,uuid,west,south,north,east,title,timebegin,timeend from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' and timebegin is not null";
$this->view->rows=$this->db->fetchAll($sql);
}
functiontimelineAction()
{
$fn="heihetime.xml";
$rows=$this->db->fetchAll("select ts_created from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' order by ts_created desc limit 1");
$rows=$this->db->fetchAll("select id,uuid,description,title,timebegin,timeend from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' and timebegin is not null order by timebegin,title");
$this->view->category=$this->db->fetchAll("select c.code,name,name_zh,count(*) from category c left join metadata m on c.id=m.id,categorycode cc where c.code=cc.code and m.source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' group by c.code,cc.name,cc.name_zh");
if($code>0&&$code<20){
$row=$this->db->fetchAll("select count(*) from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' and id in (select id from category where code=".$code.")");
$sum=$row[0]['count'];
$sql="select uuid,title,description,id from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' and id in (select distinct id from category where code=".$code.") order by timebegin,title limit ? offset ?";
$state=$this->db->query("select count(*) from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' and id in (select id from keyword where keytype='".$type."' and keyword='".$keyword."')");
$row=$state->fetchAll();
$sum=$row[0]['count'];
//@todo: add order with title
$sql="select uuid,title from metadata where source='e3ad32dc-f573-11e0-aa7b-b768cfd88d80' and id in (select id from keyword where keytype='".$type."' and keyword='".$keyword."') order by timebegin,title limit ? offset ?";