I have a simple stored procedure in MySQL database:
DELIMITER $$
CREATE DEFINER=`vidhu`@`%` PROCEDURE `test`(var_datain TEXT)
BEGIN
SELECT var_datain;
END
When calling this procedure in mysql-workbench it returns the data I put in:
Now when I call it from PHP using pdo I get an error:
Fatal error: Cannot pass parameter 2 by reference in C:/apache......(3rd line)
Here is my php code:
$db = new PDO(DSN, DBUSER, DBPASS);
$stmt = $db->prepare("CALL test(?)");
$stmt->bindParam(1, 'hai!', PDO::PARAM_STR);
$rs = $stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo $result[0];
See Question&Answers more detail:os