Home > database > mysql_func_template.m

mysql_func_template

PURPOSE ^

MySQL connection and argument checking utility.

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 MySQL connection and argument checking utility.
 mysql_func_template.m

 function outargs = myfunc(varargin)

 Template script for checking input arguments for a connection ID and
 establishing a connection if necessary.

 This is good for various utility scripts that are used to retrieve specific
 pieces of information from the database

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % MySQL connection and argument checking utility.
0002 % mysql_func_template.m
0003 %
0004 % function outargs = myfunc(varargin)
0005 %
0006 % Template script for checking input arguments for a connection ID and
0007 % establishing a connection if necessary.
0008 %
0009 % This is good for various utility scripts that are used to retrieve specific
0010 % pieces of information from the database
0011 %
0012 
0013 % Do some input parameter checking.
0014 % Modify min_arg and max_arg accordingly for your function
0015 min_arg = 1;
0016 max_arg = 2;
0017 
0018 msg = nargchk(min_arg,max_arg,nargin);
0019 if ~isempty(msg)
0020   disp(msg)
0021   return
0022 end
0023 
0024 % Parse the input arguments
0025 narg = length(varargin);
0026 for iarg = 1:2:narg
0027   switch varargin{iarg}
0028     case 'conn_id'
0029       conn_id = varargin{iarg+1};
0030     otherwise
0031       fprintf('get_qtxt: Unknown input argument: %s\n', varargin{iarg});
0032   end
0033 end
0034 
0035 % Check for valid connection to database
0036 if ~exist('conn_id','var') || isempty(conn_id) || mysql(conn_id,'status')
0037   error('%s: Do not have a valid connection ID', mfilename);
0038 end
0039 
0040 % INSERT FUNCTION SPECIFICS HERE
0041 
0042 return

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