search

Home  >  Q&A  >  body text

I would like to ask you a basic statement. Is there any conflict between SET and SELECT in mysql stored procedure?

.php page code

<?php require '数据库连接.php'; ?>
<?php
$result=$conn->query("CALL 存储过程名('$入参',@出参1,@出参2)");
$result=$conn->query("SELECT @出参1,@出参2");
$recordset=mysqli_fetch_assoc($result);
$exeout_aaa=$recordset["@出参1"];
$exeout_bbb=$recordset["@出参2"];
$result->free();//释放内存
$conn->close();//关闭连接
?>
<div>---|<?php echo $exeout_aaa; ?>|---</div>
<div>---|<?php echo $exeout_bbb; ?>|---</div>


mysql stored procedure (cannot be printed using this .php page)

CREATE DEFINER=`数据库名`@`%` PROCEDURE `存储过程名`(
IN 入参 VARCHAR(255)
,OUT 出参1 VARCHAR(255)
,OUT 出参2 int
)
BEGIN
    DECLARE temp_111 int;
    SET 出参1='测试出参1';
    SET 出参2=10;
    SELECT COUNT(*) INTO temp_11 from 表A 字段=入参;
END


mysql stored procedure (the SELECT line is commented, the .php page can be printed)

CREATE DEFINER=`数据库名`@`%` PROCEDURE `存储过程名`(
IN 入参 VARCHAR(255)
,OUT 出参1 VARCHAR(255)
,OUT 出参2 int
)
BEGIN
    DECLARE temp_111 int;
    SET 出参1='测试出参1';
    SET 出参2=10;
    #SELECT COUNT(*) INTO temp_11 from 表A 字段=入参;
END
**越狱兔**越狱兔1932 days ago964

reply all(0)I'll reply

No reply
  • Cancelreply