# HG changeset patch # User Daniele Nicolodi # Date 1323098406 -3600 # Node ID 7afc99ec5f04a9c5c2c5997744cc5d7a0b883537 # Parent 91f21a0aab355a52065e8896df8fdf6dc59e419c Update ao_model_retrieve_in_timespan diff -r 91f21a0aab35 -r 7afc99ec5f04 m-toolbox/m/built_in_models/ao/ao_model_retrieve_in_timespan.m --- a/m-toolbox/m/built_in_models/ao/ao_model_retrieve_in_timespan.m Mon Dec 05 16:20:06 2011 +0100 +++ b/m-toolbox/m/built_in_models/ao/ao_model_retrieve_in_timespan.m Mon Dec 05 16:20:06 2011 +0100 @@ -145,10 +145,6 @@ % Get parameters names = pl.find('names'); - hostname = pl.find('hostname'); - database = pl.find('database'); - username = pl.find('username'); - password = pl.find('password'); binary = utils.prog.yes2true(pl.find('binary')); constraints = pl.find('constraints'); fstol = pl.find('fstol'); @@ -177,15 +173,7 @@ start = time(start); stop = time(time(start) + nsecs); end - - if ~isRow(start) - start = start'; - end - - if ~isRow(stop) - stop = stop'; - end - + ts = timespan(start, stop); % prepare output @@ -196,10 +184,8 @@ names = {names}; end - % get a connection - conn = utils.jmysql.connect(hostname, database, username, password); - conn.openConnection(); - c = conn.getConn(); + % get database connection + conn = LTPDADatabaseConnectionManager().connect(pl); % loop over the channels for jj = 1:length(names) @@ -231,13 +217,12 @@ % execute query try utils.helper.msg(msg.PROC2, 'running query: %s', q); - rows = utils.jmysql.execute(c, q, name, ... + rows = utils.mysql.execute(conn, q, name, ... format(ts.startT, 'yyyy-mm-dd HH:MM:SS', 'UTC'), ... format(ts.endT, 'yyyy-mm-dd HH:MM:SS', 'UTC')); catch ex % close connection - c.close(); - conn.setLocked(false); + conn.close(); % back-compatibility if isempty(find(pl, 'bbb')) @@ -287,18 +272,15 @@ end % end loop over channels - % close connection - c.close(); - conn.setLocked(false); + % close connection if we own it + if isempty(find(pl, 'conn')) + conn.close(); + end; varargout{1} = a; end -function res = isRow(in) - res = (size(in,1) == 1 && size(in,2) ~= 1); -end - %-------------------------------------------------------------------------- % AUTHORS SHOULD NOT NEED TO EDIT BELOW HERE %--------------------------------------------------------------------------