diff --git a/Westdc/Mail/Template.php b/Westdc/Mail/Template.php index 18ed104..312a95d 100644 --- a/Westdc/Mail/Template.php +++ b/Westdc/Mail/Template.php @@ -35,10 +35,6 @@ class Template implements ServiceManagerAwareInterface public function insert($data,$id=0) { - if($this->fetch($data['template'])) - { - return"该邮件模板已经存在!"; - } $dbhService = $this->serviceManager->get('Db'); $dbh = $dbhService->getDbh(); @@ -48,13 +44,33 @@ class Template implements ServiceManagerAwareInterface $data['subject']='未命名模板'; } - // 替换邮件内容中的'为'' + // 替换邮件内容中的 ' 为 '' $data['body']=str_replace("'","''",$data['body']); $rs = $dbh->insert('emailtext',$data,1); return $rs; } + //删除邮件模板 + public function del($id) + { + $sql = "DELETE FROM emailtext WHERE id=$id"; + $rs = $this->db->exec($sql); + return $rs; + } + + //更新邮件模板 + public function update($table,$data,$id) + { + $dbhService = $this->serviceManager->get('Db'); + $dbh = $dbhService->getDbh(); + + // 替换邮件内容中的 ' 为 '' + $data['body']=str_replace("'","''",$data['body']); + $rs = $dbh->update('emailtext',$data,"id=$id",1); + return $rs; + } + public function fetch($key) { if(is_numeric($key))