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.
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