Gri*_*eni 5 mysql wordpress stored-procedures
我已经在MysQL中为Wordpress数据库创建了一个存储过程。这一程序的目的是为了注册一个新用户到WordPress数据库使用凭证(user_login,user_pass,user_nicename,user_email,和displayname。)这个程序的SQL语法是好的,但是当我打电话的过程我不能得到响应任何东西,这东西会告诉如果新用户已添加到数据库中。我不知道问题出在哪里,因为在调用该过程后,当我登录数据库时,我看不到任何更改。
-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$
CREATE DEFINER=`root`@`127.0.0.1` PROCEDURE `registerWithCredentials`(IN in_userlogin VARCHAR(50), IN in_userpass VARCHAR(32),IN in_usernicename VARCHAR(50) ,IN in_useremail VARCHAR(50), IN in_displayname VARCHAR(50))
proc_main:BEGIN
BEGIN
DECLARE ID int(10);
DECLARE CheckExists INT;
SET CheckExists=0;
select count(*) into CheckExists from wp_users where user_login like in_userlogin or user_email like in_useremail;
if (CheckExists>0)
then
leave proc_main;
end if;
if (in_userpass is not null or in_userpass !='') and (in_useremail is not null or in_useremail !='')
then
insert into prod_huselbrand_db.wp_users (
user_login
,user_pass
.user_nicename
,user_email
,display_name
) VALUES (
in_userlogin -- username - IN varchar(50)
-- email - IN varchar(50)
,MD5(in_userpass) -- passwd - IN blob ,
,in_usernicename
,in_useremail
,in_displayname
);
else
leave proc_main;
end if;
set ID:=LAST_INSERT_ID();
end;
END proc_main
Run Code Online (Sandbox Code Playgroud)
我认为您需要在代码末尾进行选择,以便可以从存储过程中输出某些内容。如果我像你一样,我将输出新注册用户的数据。以下是程序,希望对您有所帮助:
-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$
CREATE DEFINER=`root`@`127.0.0.1` PROCEDURE `registerWithCredentials`(IN in_userlogin VARCHAR(50), IN in_userpass VARCHAR(32),IN in_usernicename VARCHAR(50) ,IN in_useremail VARCHAR(50), IN in_displayname VARCHAR(50))
proc_main:BEGIN
BEGIN
DECLARE ID int(10);
DECLARE CheckExists INT;
SET CheckExists=0;
select count(*) into CheckExists from wp_users where user_login like in_userlogin or user_email like in_useremail;
if (CheckExists>0)
then
leave proc_main;
end if;
if (in_userpass is not null or in_userpass !='') and (in_useremail is not null or in_useremail !='')
then
insert into prod_huselbrand_db.wp_users (
user_login
,user_pass
.user_nicename
,user_email
,display_name
) VALUES (
in_userlogin -- username - IN varchar(50)
-- email - IN varchar(50)
,MD5(in_userpass) -- passwd - IN blob ,
,in_usernicename
,in_useremail
,in_displayname
);
else
leave proc_main;
end if;
set ID:=LAST_INSERT_ID();
select ID, user_login, user_pass, user_nicename, user_email, display_name
from prod_huselbrand_db.wp_users where ID = ID;
end;
END proc_main
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
78 次 |
| 最近记录: |