add attachment table name define in Reference module

This commit is contained in:
Jianxuan Li 2014-12-30 19:49:04 +08:00
parent 6f6b0ecb9a
commit 649edb70b5
1 changed files with 13 additions and 1 deletions

View File

@ -46,6 +46,7 @@ class Reference extends AbstractEventManager implements ServiceManagerAwareInter
$this->table->metadata_reference = "mdref"; $this->table->metadata_reference = "mdref";
$this->table->reference_tag = "ref_tag"; $this->table->reference_tag = "ref_tag";
$this->table->metadata = "metadata"; $this->table->metadata = "metadata";
$this->table->attachments = "attachments";
} }
/** /**
@ -398,9 +399,20 @@ class Reference extends AbstractEventManager implements ServiceManagerAwareInter
//获得reference类型的附件 //获得reference类型的附件
public function getReferenceFiles() public function getReferenceFiles()
{ {
$wheresql = [
"att.filetype='literature'",
];
if(!empty($this->keyword))
{
$wheresql[] = " (att.realname LIKE '%{$this->keyword}%' OR att.filename LIKE '%{$this->keyword}%') ";
}
$wheresql = " WHERE ".join(" AND ",$wheresql);
$sql = "SELECT att.*,ref.attid,ref.id as refid FROM {$this->table->attachments} att $sql = "SELECT att.*,ref.attid,ref.id as refid FROM {$this->table->attachments} att
LEFT JOIN {$this->table->reference} ref ON att.id=ref.attid LEFT JOIN {$this->table->reference} ref ON att.id=ref.attid
WHERE att.filetype='literature'"; $wheresql";
$rs = $this->db->query($sql); $rs = $this->db->query($sql);
$rows = $rs->fetchAll(); $rows = $rs->fetchAll();
return $rows; return $rows;