note 78962 deleted from book.pdo by cmb
| From: | cmb@php.net | Date: | Fri, 06 Sep 2019 17:25:11 +0000 |
| Subject: | note 78962 deleted from book.pdo by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212109@lists.php.net to get a copy of this message | ||
Note Submitter: xorinox at vtxmail dot ch
----
I have seen a lot of user struggling with calling mysql procedures with in/out/inout parameters
using bindParam. There seems to be a bug or missing feature within the mysql C api. This at least I
could find out after reading a lot of posts at different places...
At the moment I workaround it like below. $con is a PDO object:
<?php
//in
$proc = $con->prepare( "call proc_in( @i_param )" );
$con->query( "set @i_param = 'myValue'" );
$proc->execute();
//out
$proc = $con->prepare( "call proc_out( @o_param )" );
$proc->execute();
$o_param = $con->query( "select @o_param" )->fetchColumn();
//inout
$proc = $con->prepare( "call proc_inout( @io_param )" );
$con->query( "set @io_param = 'myValue'" );
$proc->execute();
$io_param = $con->query( "select @io_param" )->fetchColumn();
?>