From 649edb70b5dd600dae3e8f0ae10bf4dc797e461a Mon Sep 17 00:00:00 2001 From: Jianxuan Li Date: Tue, 30 Dec 2014 19:49:04 +0800 Subject: [PATCH] add attachment table name define in Reference module --- Westdc/Reference/Reference.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Westdc/Reference/Reference.php b/Westdc/Reference/Reference.php index 68c3417..e126cd0 100644 --- a/Westdc/Reference/Reference.php +++ b/Westdc/Reference/Reference.php @@ -46,6 +46,7 @@ class Reference extends AbstractEventManager implements ServiceManagerAwareInter $this->table->metadata_reference = "mdref"; $this->table->reference_tag = "ref_tag"; $this->table->metadata = "metadata"; + $this->table->attachments = "attachments"; } /** @@ -398,9 +399,20 @@ class Reference extends AbstractEventManager implements ServiceManagerAwareInter //获得reference类型的附件 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 LEFT JOIN {$this->table->reference} ref ON att.id=ref.attid - WHERE att.filetype='literature'"; + $wheresql"; $rs = $this->db->query($sql); $rows = $rs->fetchAll(); return $rows;