add viewed field

This commit is contained in:
wlx 2014-06-11 13:13:58 +00:00
parent a6035e7f60
commit 153a43956e
1 changed files with 5 additions and 3 deletions

View File

@ -127,7 +127,7 @@ class DataController extends Zend_Controller_Action
if (empty($page)) $page=1; if (empty($page)) $page=1;
$limit=10; $limit=10;
$offset=$limit*($page-1); $offset=$limit*($page-1);
$sql='select keyword,count(*),keytype from keyword right join normalmetadata on keyword.id=normalmetadata.id '; $sql="select keyword,count(*),keytype from keyword right join $this->submd m on keyword.id=m.id ";
if (!empty($keytype) && ($keytype=='place' || $keytype=='theme' || $keytype=='discipline'||$keytype=='temporal')) $sql.=" where keytype='".$keytype."'"; if (!empty($keytype) && ($keytype=='place' || $keytype=='theme' || $keytype=='discipline'||$keytype=='temporal')) $sql.=" where keytype='".$keytype."'";
$sql.=' group by keyword,keytype order by keytype,keyword,count desc'; $sql.=' group by keyword,keytype order by keytype,keyword,count desc';
$state=$this->db->query($sql); $state=$this->db->query($sql);
@ -140,13 +140,15 @@ class DataController extends Zend_Controller_Action
$key=$row->name; $key=$row->name;
} }
$this->view->codename=$key; $this->view->codename=$key;
$sql=$this->db->quoteInto('select count(m.id) from normalmetadata m,keyword k where m.id=k.id and k.keyword=?',$key); $sql=$this->db->quoteInto("select count(m.id) from $this->submd m,keyword k where m.id=k.id and k.keyword=?",$key);
$state=$this->db->query($sql); $state=$this->db->query($sql);
$row=$state->fetchAll(); $row=$state->fetchAll();
$sum=$row[0]['count']; $sum=$row[0]['count'];
$select=$this->db->select(); $select=$this->db->select();
$select->from('normalmetadata','*')->join('keyword','normalmetadata.id=keyword.id')->where('keyword.keyword=?',$key)->order('normalmetadata.title')->limitPage($page,$limit); $select->from($this->submd.' as m','*')
->join('keyword','m.id=keyword.id')
->join('mdstat as ms','ms.uuid=m.uuid','viewed')->where('keyword.keyword=?',$key)->order('m.title')->limitPage($page,$limit);
//$sql=$db->quoteInto('select m.* from metadata m,keyword k where m.id=k.id and k.keyword=?',$key); //$sql=$db->quoteInto('select m.* from metadata m,keyword k where m.id=k.id and k.keyword=?',$key);
//$state=$db->query($sql); //$state=$db->query($sql);
$this->view->metadata=$this->db->fetchAll($select); $this->view->metadata=$this->db->fetchAll($select);