如何使用php
获取/存储mysql函数在变量中的返回值 Delimiter $
CREATE FUNCTION FP_USER_EXISTS(xemailid VARCHAR(50)) RETURNS int(11)
BEGIN
SET @User_exists = 0;
SELECT COUNT(*) INTO @found FROM login WHERE emailid = xemailid;
IF @found > 0 THEN
SET @User_exists = 1;
END IF;
RETURN @User_exists;
END $$
在mysql中调用函数
@return=FP_USER_EXISTS('testing@test.com')
select @return here it shows return value 0 or 1
但是在php中它不是值得的值
$ret=mysqli_query($connection,"select FP_USER_EXISTS('$emailid')");
if($ret==1)
{
echo "User already exits";
}
else
{
echo 'Inserted successfully';
}
每次根据条件显示一个值 感谢