PDO stored procedures php5.1 mysql5
am 18.02.2007 19:02:48 von gxjw-3301Hello,
I've some problems with calling stored procedures.
When I try to execute the demonstration example on php.net I get no result, but
it works with normal SQL-commandqueries
software: MAMP-package: php 5.1.6, mysql 5.0.19, apache 2.0.59
my stored procedure is for this example returns a string:
CREATE PROCEDURE stringi(OUT result VARCHAR(30)) BEGIN SELECT text INTO result
FROM checker WHERE id = 1;
it works with sql queries like: 'CALL stringi(@a)' - 'SELECT @a'
so the stored procedure should be working correctly, or did i miss something?
Thanks ahead for any advise!
--------------------------------------------
the first code is the one from php.net that doesn't work:
code-output: "procedure returned mysql"
try{
$dbh = new PDO('mysql:host=localhost;dbname=test', 'user', 'password');
$stmt = $dbh->prepare("CALL stringi(?)");
$stmt->bindParam(1, $return_value, PDO::PARAM_STR, 4000);
// call the stored procedure
$stmt->execute();
print "procedure returned $return_value\n";
echo $dbh->getAttribute(PDO::ATTR_DRIVER_NAME);
}
catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "
";
die();
}
this is the example described above that works
output: "Array ( [@a] => baer [0] => baer ) mysql"
try{
$dbh = new PDO('mysql:host=localhost;dbname=test', 'user', 'password');
$dbh->query('CALL stringi(@a)');
foreach($dbh->query('SELECT @a') as $foo)
print_r($foo).' br>';
echo $dbh->getAttribute(PDO::ATTR_DRIVER_NAME);
}
catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "
";
die();
}
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php