Skip to content

Instantly share code, notes, and snippets.

@vjaro
Created April 8, 2020 17:07
Show Gist options
  • Save vjaro/50a6c7e84ef38a45f525e1aaf9de1216 to your computer and use it in GitHub Desktop.
Save vjaro/50a6c7e84ef38a45f525e1aaf9de1216 to your computer and use it in GitHub Desktop.
How to create MySQL Stored Functions using PDO in SugarCRM
DROP FUNCTION IF EXISTS getAge;
CREATE FUNCTION getAge(date_of_birth DATE) RETURNS INT
BEGIN
DECLARE age INT DEFAULT 0;
SELECT TIMESTAMPDIFF(YEAR,date_of_birth,CURDATE()) INTO age;
RETURN age;
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment