dbService = $this->getServiceManager()->get('Db'); $this->db = $this->dbService->getPdo(); $this->table = new \stdClass; $this->table->reference = "reference"; $this->table->reference_author = "ref_author"; $this->table->reference_tag = "ref_tag"; } //检查ris中的文献是否已经存在 public function checkRisReference(EventInterface $e) { $ref = $e->getParam('ref'); $wheresql = array(); if(preg_match("/\'/",$ref['title'])) { $ref['title'] = preg_replace("/\'/","''",$ref['title']); } $wheresql[] = " lower(title)=lower('{$ref['title']}') "; $wheresql[] = " year='{$ref['year']}' "; //暂时不使用期刊限制 /*if(isset($ref['publisher'])) { $wheresql[] = " publisher='{$ref['publisher']}' "; }*/ if(count($wheresql) > 0) { $wheresql = " WHERE ".join(" and ",$wheresql); }else{ $wheresql = ""; } $sql="select * from {$this->table->reference} $wheresql"; $sth=$this->db->query($sql); $row=$sth->fetch(); $id=$row['id']; if(!empty($row['id'])) { return $id; }else{ return 0; } } //删除作者 public function deleteAuthor(EventInterface $e) { $id = $e->getParam('id'); $sql = "DELETE FROM {$this->table->reference_author} WHERE id=$id "; return $this->db->exec($sql); } public function deleteTag(EventInterface $e) { $id = $e->getParam('id'); $sql = "DELETE FROM {$this->table->reference_tag} WHERE id=$id "; return $this->db->exec($sql); } }