Home > m > mysql > mysql_getUserID.m

mysql_getUserID

PURPOSE ^

MYSQL_GETUSERID gets the user ID number corresponding to the given user name.

SYNOPSIS ^

function [userid,dbuser] = mysql_getUserID(conn, username)

DESCRIPTION ^

 MYSQL_GETUSERID gets the user ID number corresponding to the given user name.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: MYSQL_GETUSERID gets the user ID number corresponding to the
              user name that connected to the MySQL database.

 CALL:        userid = mysql_getUserID(conn)

 VERSION:     $Id: mysql_getUserID.m,v 1.7 2008/02/24 10:16:58 hewitson Exp $

 HISTORY:     24-05-2007 M Hewitson
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [userid,dbuser] = mysql_getUserID(conn, username)
0002 % MYSQL_GETUSERID gets the user ID number corresponding to the given user name.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: MYSQL_GETUSERID gets the user ID number corresponding to the
0007 %              user name that connected to the MySQL database.
0008 %
0009 % CALL:        userid = mysql_getUserID(conn)
0010 %
0011 % VERSION:     $Id: mysql_getUserID.m,v 1.7 2008/02/24 10:16:58 hewitson Exp $
0012 %
0013 % HISTORY:     24-05-2007 M Hewitson
0014 %                 Creation
0015 %
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 
0018 userid = [];
0019 try
0020   q    = sprintf('select id from users where username="%s"', conn.Username);
0021   curs = exec(conn, q);
0022   curs = fetch(curs);
0023   userid = curs.Data{1};
0024   close(curs);
0025 catch
0026   warning('!!! Unable to retrieve user ID. [Server returned: %s]', curs.Message);
0027 end
0028 
0029 % END

Generated on Mon 31-Mar-2008 13:54:54 by m2html © 2003