Westdc\Mail\Template tools CURD

This commit is contained in:
shayupi@qq.com 2014-12-19 21:17:03 +08:00
parent d5e6c1e1be
commit 80a91fd4d5
1 changed files with 21 additions and 5 deletions

View File

@ -35,10 +35,6 @@ class Template implements ServiceManagerAwareInterface
public function insert($data,$id=0) public function insert($data,$id=0)
{ {
if($this->fetch($data['template']))
{
return"该邮件模板已经存在!";
}
$dbhService = $this->serviceManager->get('Db'); $dbhService = $this->serviceManager->get('Db');
$dbh = $dbhService->getDbh(); $dbh = $dbhService->getDbh();
@ -55,6 +51,26 @@ class Template implements ServiceManagerAwareInterface
return $rs; 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) public function fetch($key)
{ {
if(is_numeric($key)) if(is_numeric($key))