/** * Constructor * * @param string $mailChimpUser * @param string $mailChimpPassword * @param array $users */ function __construct($mcApiKey, array $users) { $this->_users = $users; unset($users); foreach ($this->_users as $i => $user) { $this->_keys[$user['EMAIL']] = $i; } parent::__construct($mcApiKey); }
/** * Syncs a database table w/ MailChimp * * The last three parameters are optional if you passed them in the constructor. * $mergeColumns should be an array of DBCOLNAME => MERGEVARNAME * * @param string $listId * @param string $query * @param string $userExistsQuery * @param string $emailColumn * @param array $mergeColumns */ public function sync($listId) { $arguments = func_get_args(); // Populate Query if (isset($arguments[1])) { $this->_query = $arguments[1]; } // User exists query if (isset($arguments[2])) { $this->_userExistsQuery = $arguments[2]; } // Populate Merge Columns if (isset($arguments[3])) { $this->_mergeColumns = $arguments[3]; } // Error check if (!in_array('EMAIL', $this->_mergeColumns)) { throw new Exception('Your merge columns must at minimum include an EMAIL field.'); } parent::sync($listId); }