Home > database > mysql_get_qtxt.m

mysql_get_qtxt

PURPOSE ^

Retrieves text associated with questions specified by the vector of qids

SYNOPSIS ^

function qtxt = mysql_get_qtxt(qids,varargin)

DESCRIPTION ^

 Retrieves text associated with questions specified by the vector of qids

 qtxt = get_qtxt(qids,varargin)

 A flexible number of options can be passed into the function as tag/value
 pairs.

 'conn_id', conn_id - the ID of the mysql connection - REQUIRED

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function qtxt = mysql_get_qtxt(qids,varargin)
0002 % Retrieves text associated with questions specified by the vector of qids
0003 %
0004 % qtxt = get_qtxt(qids,varargin)
0005 %
0006 % A flexible number of options can be passed into the function as tag/value
0007 % pairs.
0008 %
0009 % 'conn_id', conn_id - the ID of the mysql connection - REQUIRED
0010 
0011 % Parse the input arguments
0012 narg = length(varargin);
0013 for iarg = 1:2:narg
0014   switch varargin{iarg}
0015     case 'conn_id'
0016       conn_id = varargin{iarg+1};
0017     otherwise
0018       fprintf('get_qtxt: Unknown input argument: %s\n', varargin{iarg});
0019   end
0020 end
0021 
0022 % Check for valid connection to database
0023 if ~exist('conn_id','var') || isempty(conn_id) || mysql(conn_id,'status')
0024   error('%s: Do not have a valid connection ID', mfilename);
0025 end
0026 
0027 qid_str = sprintf('%d,', qids);
0028 qid_str = sprintf('(%s)', qid_str(1:end-1));
0029 
0030 mysql_str = sprintf(['SELECT question_text FROM question ' ...
0031       'WHERE question_id IN %s;'], qid_str);
0032 
0033 qtxt = mysql(conn_id,mysql_str);
0034 
0035 return

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003