doulangxun7769 2017-02-10 11:44
浏览 29

如何通过PHP mysqli访问MySQL OUT变量而没有结果集

Is it possible to access an OUT variable from an SP called through mysqli without returning it via SELECT one way or another? I had a good look and tried the code here but it always needs a result set called within or after the SP to work.

Consider this code:

SQL:

DELIMITER $

# DROP PROCEDURE IF EXISTS outVar$

CREATE PROCEDURE outVar(OUT myVar TINYINT(1))
BEGIN

    SET myVar = 1;

END$

DELIMITER ;

CALL outVar(@myVar);

SELECT @myVar;

PHP:

 <?php

    $Conn = new mysqli("127.0.0.1", "root", "123456789", "test");

    $RResult = $Conn->query("CALL outVar(@myVar);");

    print_r($RResult->fetch_assoc());
?>

This returns the following:

Fatal error: Call to a member function fetch_assoc() on boolean in C:\xampp\htdocs\phpTest.php on line 7

Because there are no results returned in tabular form, fair enough. So am I correct in assuming that while OUT is elegant within mysql it's of no use in the mysqli context without the help of a result set leaving OUT redundant in this context? If not I'd love to know how to do it.

Thanks,

James

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
    • ¥15 路易威登官网 里边的参数逆向
    • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
    • ¥50 需求一个up主付费课程
    • ¥20 模型在y分布之外的数据上预测能力不好如何解决
    • ¥15 processing提取音乐节奏
    • ¥15 gg加速器加速游戏时,提示不是x86架构
    • ¥15 python按要求编写程序
    • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入