view m-toolbox/classes/+utils/@mysql/getUserID.m @ 0:f0afece42f48
Import.
author
Daniele Nicolodi <nicolodi@science.unitn.it>
date
Wed, 23 Nov 2011 19:22:13 +0100 (2011-11-23)
parents
children
line source
+ − % GETUSERID gets the user ID number corresponding to the given user name.
+ − %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ − %
+ − % DESCRIPTION: GETUSERID gets the user ID number corresponding to the
+ − % user name that connected to the MySQL database.
+ − %
+ − % CALL: userid = getUserID(conn)
+ − %
+ − % VERSION: $Id: getUserID.m,v 1.3 2010/01/22 12:46:08 ingo Exp $
+ − %
+ − % HISTORY: 24-05-2007 M Hewitson
+ − % Creation
+ − %
+ − %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ −
+ − function [userid,dbuser] = getUserID(conn, username)
+ −
+ − error('### Obsolete as of LTPDA version 2.2. Replaced my the utils class jmysql (utils.jmysql.%s)', mfilename());
+ −
+ − userid = [];
+ − try
+ − q = sprintf('select id from users where username="%s"', conn.Username);
+ − curs = exec(conn, q);
+ − curs = fetch(curs);
+ − userid = curs.Data{1};
+ − close(curs);
+ − catch curs
+ − warning('!!! Unable to retrieve user ID. [Server returned: %s]', curs.message);
+ − end
+ −
+ − end
+ −