<?php
require_once (PATH_MODELS . "base/MasterBase.php") ;
require_once (PATH_TABLES . "general/EmailLogTable.php") ;

class EmailLogClass extends MasterBase {

	function __construct($db) {
		$this->db = $db ;
		$this->tbl = EmailLogTable::C_TABLE ;
		$this->fldid = EmailLogTable::C_ID ;
	}
	
	function __destruct() {
	}
	
	function addRecord($datas) {
		$sql = "insert into " . $this->tbl ." (".EmailLogTable::C_EMAIL_ID.", ".EmailLogTable::C_TRAN_TYPE.", ".EmailLogTable::C_TRAN_ID.") VALUES";
		$params = array() ;	
		$sql_temp = array() ;	
		try {
			if (is_array($datas) && count($datas) > 0) {
				foreach ($datas as $data) {
					$val = array();
					$val [] = $this->db->formatValueParam(EmailLogTable::C_EMAIL_ID);
					$val [] = $this->db->formatValueParam(EmailLogTable::C_TRAN_TYPE);
					$val [] = $this->db->formatValueParam(EmailLogTable::C_TRAN_ID);
					$val = implode(',', $val);
					$sql_temp[]= " (" . $val . ")";				
					$params[] = $this->db->valueParam(EmailLogTable::C_EMAIL_ID,$data[EmailLogTable::C_EMAIL_ID]) ;
					$params[] = $this->db->valueParam(EmailLogTable::C_TRAN_TYPE,$data[EmailLogTable::C_TRAN_TYPE]) ;
					$params[] = $this->db->valueParam(EmailLogTable::C_TRAN_ID,$data[EmailLogTable::C_TRAN_ID]) ;
				}
				$sql .= implode(",", $sql_temp);
				$this->db->insertRow($sql,$params) ;
				return true ;
			} else {
				return false ;
			}
		} catch (Exception $e) {
			return $e->getMessage(); ;
		}
	}

}
?>