mysql 存储过程 with_mysql – registerWithCredentials()存储过程

我在MysQL中为我的Wordpress数据库创建了一个存储过程.此过程的目的是使用凭据(user_login,user_pass,user_nicename,user_email和displayname)将新用户注册到wordpress数据库.

这个过程的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

解决方法:

我认为您需要在代码的末尾进行选择,以便从存储过程中输出内容.如果我喜欢你,我会输出新注册用户的数据.这是程序,希望它会有所帮助:

-- --------------------------------------------------------------------------------

-- 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

标签:wordpress,mysql,stored-procedures

来源: https://codeday.me/bug/20190624/1277143.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值