Store procedures in phpMyAdmin

前端 未结 6 1423
小蘑菇
小蘑菇 2020-11-28 15:34

I must add stored procedures to MySQL database.

The problem is that the hosting offers phpMyAdmin to manage the database.

I searched on the Intern

6条回答
  •  野性不改
    2020-11-28 15:57

    I had trouble using the 'Routines' feature in PHPMyadmin cos it kept giving me false negatives so i did it via the 'SQL' tab instead.

    CREATE PROCEDURE GetUserPwd(email VARCHAR(320), pass VARCHAR(128))
    BEGIN
    DECLARE userid INT(3) DEFAULT 0;
    DECLARE password_equal INT(3) DEFAULT 0;
    DECLARE output VARCHAR(30);
    SELECT id INTO userid FROM members WHERE user_email = email;
    IF userid != 0 THEN
    SELECT user_pass = pass INTO password_equal FROM members WHERE id = userid;
    IF password_equal = 0 THEN
    SET output = 'not exist';
    ELSE
    SET output = 'exist';
    END IF;
    END IF;
    SELECT output;
    END
    

    In the 'Delimiter' text box, type in '$$'. save.

    after that , go to your 'Routines' tab and click on 'execute' and enter your inputs when prompted.

提交回复
热议问题