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