php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77933 Unable to get Parameter Out
Submitted: 2019-04-23 17:21 UTC Modified: -
From: jose dot castro at stccorp dot net Assigned:
Status: Open Package: PDO MySQL
PHP Version: 7.2.17 OS: Windows 10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
40 - 38 = ?
Subscribe to this entry?

 
 [2019-04-23 17:21 UTC] jose dot castro at stccorp dot net
Description:
------------
$outdata = 0;
$stmt = $pdo->prepare("CALL sp_insert_test(?,?,?,?,?,?)");
$stmt->bindParam(1, $d1, PDO::PARAM_INT);
$stmt->bindParam(2, $dtype, PDO::PARAM_STR);
$stmt->bindParam(3, $d2, PDO::PARAM_INT);
$stmt->bindParam(4, $d3, PDO::PARAM_INT);
$stmt->bindParam(5, $title, PDO::PARAM_STR);
$stmt->bindParam(6, $newid, PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT);
$stmt->execute();

echo "NEW IS IS : . $newid;

Test script:
---------------
CREATE TABLE `test_table` (
  `tid` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `d1` int(10) unsigned DEFAULT NULL,
  `dtype` varchar(10) DEFAULT NULL,
  `d2` int(10) unsigned DEFAULT NULL,
  `d3` int(10) unsigned DEFAULT NULL,
  `title` varchar(200) DEFAULT NULL,
  `dateCreated` datetime NOT NULL,
  `dateUpdated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`tid`),
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

CREATE PROCEDURE sp_insert_test(IN p_d1 INT,IN p_dtype VARCHAR(10),IN p_d2 INT,IN p_d3 INT,IN p_title VARCHAR(200), OUT p_out INT)
BEGIN

INSERT INTO test_table (d1,dtype,d2,d3,title,dateCreated) values (p_d1,p_dtype,p_d2,p_d3,p_title,NOW());

SELECT LAST_INSERT_ID() INTO p_out;

END

Expected result:
----------------
Expected the last id of the table

Additional info:
MYSQL version: 5.7.19

Actual result:
--------------
always get 0

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Sep 23 18:01:26 2019 UTC