What is the case with mysql stored procs and PDO. Spent an hour googling and all I get is conflicting comments that you can or can not access the results of a stored proc.
Otherwise, what is wrong with this
$dbh = new PDO('mysql:host=host;dbname=db', 'user', 'pass');
$stmt = $dbh->prepare('CALL spLogin(?,?,?,?,?)');
$stmt->bindParam(1, $uid, PDO:ARAM_STR);
$stmt->bindParam(2, $pwd, PDO:ARAM_STR);
$stmt->bindParam(3, $clientid, PDO:ARAM_INT, 10);
$stmt->bindParam(4, $uid, PDO:ARAM_STR, 50);
$stmt->bindParam(5, $admin, PDO:ARAM_BOOL, 1);
$stmt->execute();
if (is_null($clientid)) {
error('A database error occurred while checking your '.
'login details.\\nIfhis error persists, please '.
'contact me@mydomain');
All I get is the error message and it is doing me in.Example 1643. Calling a stored procedure with an input/output parameter
<?php
$stmt = $dbh->prepare("CALL sp_takes_string_returns_string(?)");
$value = 'hello';
$stmt->bindParam(1, $value, PDO:ARAM_STR|PDO:ARAM_INPUT_OUTPUT, 4000);
// call the stored procedure
$stmt->execute();
print "procedure returned $value\n";
?>
Looks like you need to specify which variable should contain the SP return value.
Otherwise, what is wrong with this
$dbh = new PDO('mysql:host=host;dbname=db', 'user', 'pass');
$stmt = $dbh->prepare('CALL spLogin(?,?,?,?,?)');
$stmt->bindParam(1, $uid, PDO:ARAM_STR);
$stmt->bindParam(2, $pwd, PDO:ARAM_STR);
$stmt->bindParam(3, $clientid, PDO:ARAM_INT, 10);
$stmt->bindParam(4, $uid, PDO:ARAM_STR, 50);
$stmt->bindParam(5, $admin, PDO:ARAM_BOOL, 1);
$stmt->execute();
if (is_null($clientid)) {
error('A database error occurred while checking your '.
'login details.\\nIfhis error persists, please '.
'contact me@mydomain');
All I get is the error message and it is doing me in.Example 1643. Calling a stored procedure with an input/output parameter
<?php
$stmt = $dbh->prepare("CALL sp_takes_string_returns_string(?)");
$value = 'hello';
$stmt->bindParam(1, $value, PDO:ARAM_STR|PDO:ARAM_INPUT_OUTPUT, 4000);
// call the stored procedure
$stmt->execute();
print "procedure returned $value\n";
?>
Looks like you need to specify which variable should contain the SP return value.