function write_to_sql_database(table,colnames,extdata,whereclause_info,database_modification_style)
%description: uses the database toolbox and sql syntax to 'update' selected fields from selected records; can be used in conjunction with simple_database_querier for manual changes
%called by: simpleteetester
%calls: [no custom functions
%notes:
%code confirm date:

conn = database('dwn_test', 'root', 'testpass', 'com.mysql.jdbc.Driver','jdbc:mysql://localhost:3306/dwn_test');
setdbprefs('datareturnformat','cellarray');

if database_modification_style==1   %USE THIS FORM WHEN FEEDING IN DATA FROM ANOTHER M-FILE, WITH ONE CALL TO THIS M-FILE PER DATUM
	%extdatastr=num2str(extdata); %use when string data is required by the database
	extdatacell{1}=extdata;
	colnamescell{1}=colnames;
	update(conn,table,colnamescell, extdatacell,whereclause_info)
elseif database_modification_style==2   %USE THIS FORM WHEN FEEDING IN DATA AS CELL ARRAYS WITH WHERECLAUSE INFO TELLING WHERE EACH DATUM IS PLACED
	for i=1:size(whereclause_info,1)
        colnamescell{1}=colnames;
        datacell{1}=num2str(extdata{i});
        %extdatastr=num2str(extdata(1,:));   %as is, THIS ADDS THE SAME VALUE TO ALL SLOTS
        %extdatacell{1}=extdatastr;
        update(conn,table,colnamescell,datacell,strcat('WHERE first_patchlogfile_this_expt=''', whereclause_info{i}, ''''))
	end
end

close(conn)
end