<?php
class ModelAccountNewsletter extends Model {

	public function addNewsletter($email, $name = null){
        $sql = "INSERT INTO " . DB_PREFIX . "newsletter SET email = '" . $this->db->escape($email) . "'"
            . ( $name ? ", name = '" . $this->db->escape($name) . "'" : '');
		$this->db->query($sql);

	}

    public function deleteNewsletter($email){

        $this->db->query("DELETE FROM " . DB_PREFIX . "newsletter WHERE email = '" . $this->db->escape($email) . "'");

    }

	public function getNewsletterByEmail($email){

		$query = $this->db->query("SELECT * FROM ". DB_PREFIX ."newsletter WHERE email = '" . $this->db->escape($email) . "'");

		if($query->rows){
			return true;
		}else{
			return false;
		}

	}

}
