Home > database > mysql_question_enum_vals.m

mysql_question_enum_vals

PURPOSE ^

Returns a cell array of strings containing the enum labels for a given

SYNOPSIS ^

function enum_vals = mysql_question_enum_vals(question_id, subquestion, conn_id)

DESCRIPTION ^

 Returns a cell array of strings containing the enum labels for a given
 combination of question_id and subquestion

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function enum_vals = mysql_question_enum_vals(question_id, subquestion, conn_id)
0002 % Returns a cell array of strings containing the enum labels for a given
0003 % combination of question_id and subquestion
0004 
0005 % 14Sep2014 Petr Janata
0006 if nargin < 3
0007   error('%s: Requires 3 input arguments', mfilename)
0008 end
0009 
0010 if isempty(subquestion)
0011   subquestion = 1;
0012 end
0013 
0014 mysql_str = sprintf(['SELECT df.enum_values FROM data_format AS df, ' ...
0015   'question_x_data_format AS qdf ' ...
0016   'WHERE df.data_format_id = qdf.answer_format_id AND qdf.question_id = %d ' ...
0017   'AND qdf.subquestion = %d;'], question_id, subquestion);
0018 
0019 enum_vals = mysql(conn_id, mysql_str);
0020 
0021 enum_vals = regexp(regexprep(enum_vals{1},'"',''),',','split');
0022 
0023 return

Generated on Wed 20-Mar-2019 04:00:51 by m2html © 2003