0001 function cb_getDBs(varargin)
0002
0003 myh = varargin{1};
0004 mainfig = varargin{4};
0005
0006 tables = {'collections', 'objmeta', 'objs', 'transactions', 'users'};
0007
0008
0009 conn = getappdata(mainfig, 'connection');
0010
0011 if isempty(conn)
0012
0013
0014 hostname = get(findobj('Tag','serverTxt'), 'String');
0015
0016
0017 [conn, username] = mysql_connect(hostname);
0018 if ~isa(conn, 'database')
0019 error('# couldn''t connect to server');
0020 end
0021 end
0022
0023
0024 q = 'show databases';
0025 curs = exec(conn, q);
0026 curs = fetch(curs);
0027
0028 ltpda_dbs = [];
0029
0030 for j=1:length(curs.Data)
0031 db = curs.Data{j};
0032
0033 if ~strcmp(db, 'information_schema')
0034
0035 q = sprintf('show tables from %s', db);
0036 c = exec(conn, q);
0037 c = fetch(c);
0038 match = 0;
0039 for l=1:length(c.Data)
0040 for k=1:length(tables)
0041 if strcmp(c.Data{l}, tables{k})
0042 match = match + 1;
0043 end
0044 end
0045 end
0046 close(c);
0047 if match == 5
0048
0049 ltpda_dbs = [ltpda_dbs cellstr(db)];
0050 end
0051 end
0052
0053 end
0054 close(curs);
0055
0056
0057 id = findobj('Tag', 'dbSelect');
0058 set(id, 'String', ltpda_dbs, 'Value', 1);
0059
0060
0061
0062