Home > database > mysql_check_conn.m

mysql_check_conn

PURPOSE ^

Checks a mysql connection, opens or closes if necessary.

SYNOPSIS ^

function status = mysql_check_conn(conn_id,action)

DESCRIPTION ^

 Checks a mysql connection, opens or closes if necessary.
 conn_id = mysql_check_conn(conn_id,action);

 Checks to see if a mysql connection with the desired ID is active and checks
 to see if there is an action that should be performed.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function status = mysql_check_conn(conn_id,action)
0002 % Checks a mysql connection, opens or closes if necessary.
0003 % conn_id = mysql_check_conn(conn_id,action);
0004 %
0005 % Checks to see if a mysql connection with the desired ID is active and checks
0006 % to see if there is an action that should be performed.
0007 
0008 % 06/15/10 PJ Sanitized mysql_make_conn
0009 
0010 if nargin < 2
0011   action = 'check';
0012 end
0013 
0014 status = mysql(conn_id,'status'); % returns 0 if active
0015 
0016 if status==0 && ~strcmp(action,'close')
0017   return
0018 end
0019 
0020 switch action
0021   case 'close'
0022     mysql(conn_id,'close');
0023     status = 1;
0024 end

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