php - Calling this stored procedure in php
问题描述
excuse me, can you please suggest me how can I call this stored procedure (https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=cdeacd70bac986d28e9a6e5cb84774c2) in php? I'd like to have those four numbers in four variables, so I can display those data on my webpage. I'm sure that I'm not understanding something. That's the code I'm using but it does not works (I get always 0):
$conn = new PDO("mysql:host=$servername;dbname=dbcbt", $username, $password);
$sql = 'CALL CountMacro_Audit_Scaduti(?,?,?,?); select @CountMacro1, @CountMacro2, @CountMacro3, @CountMacro4';
$stmt = $conn->prepare($sql);
$CountMacro1 = 0;
$CountMacro2 = 0;
$CountMacro3 = 0;
$CountMacro4 = 0;
$stmt->bindParam(1, $CountMacro1, PDO::PARAM_INT, 10);
$stmt->bindParam(2, $CountMacro2, PDO::PARAM_INT, 10);
$stmt->bindParam(3, $CountMacro3, PDO::PARAM_INT, 10);
$stmt->bindParam(4, $CountMacro4, PDO::PARAM_INT, 10);
print "Values of bound parameters _before_ CALL:\n";
print " 1: {$CountMacro1} 2: {$CountMacro2} 3: {$CountMacro3} 4: {$CountMacro4}\n";
$stmt->execute();
print "Values of bound parameters _after_ CALL:\n";
print " 1: {$CountMacro1} 2: {$CountMacro2} 3: {$CountMacro3} 4: {$CountMacro4}\n";
解决方案
推荐阅读
- python - 熊猫数据框根据其他列是否有数据添加新列
- java - 在“/storage/emulated/0/Pictures/”中找不到文件
- c++ - Clang 不能编译基本的头文件(比如
) 在 macOS 中 - android - 如何在 Android Q 中获取深度图
- java - Drools 7.x 在运行时动态加载规则而不使用 maven
- node.js - 如何同时渲染页面执行函数调用
- shopify - 如何在后端接收 Shopify 商店事件
- android - RecyclerView 除非收到通知,否则不会将数据绑定到 ViewHolder
- java - 优化递归回溯
- youtube-dl - 如何从 youtube-dl 获取已下载视频的上传者名称?