25 lines
439 B
SQL
25 lines
439 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `account`.`myUser_getId`()
|
|
RETURNS int(11)
|
|
DETERMINISTIC
|
|
READS SQL DATA
|
|
BEGIN
|
|
/**
|
|
* Returns the current user id.
|
|
*
|
|
* @return The user id
|
|
*/
|
|
DECLARE vUser INT DEFAULT NULL;
|
|
|
|
IF myUser_checkLogin()
|
|
THEN
|
|
SET vUser = @userId;
|
|
ELSE
|
|
SELECT id INTO vUser FROM user
|
|
WHERE name = LEFT(USER(), INSTR(USER(), '@') - 1);
|
|
END IF;
|
|
|
|
RETURN vUser;
|
|
END$$
|
|
DELIMITER ;
|