Die Dokumentation ist in Bezug auf Stored Procedures in mysql mit PHP sehr mangelhaft. Ich habe derzeit eine gespeicherte Prozedur, die ich über PHP aufrufen, wie kann ich den Wert eines out-Parameters erhalten?PHP + MySql + Gespeicherte Prozeduren, wie bekomme ich Zugriff auf einen "out" -Wert?
14
A
Antwort
15
es sieht aus wie es in diesem Beitrag beantwortet wird:
http://forums.mysql.com/read.php?52,198596,198717#msg-198717
Mit mysqli PHP API:
Angenommen sproc myproc (IN i int, OUT j int):
$mysqli = new mysqli( "HOST", "USR", "PWD", "DBNAME");
$ivalue=1;
$res = $mysqli->multi_query("CALL myproc($ivalue,@x);SELECT @x");
if($res) {
$results = 0;
do {
if ($result = $mysqli->store_result()) {
printf("<b>Result #%u</b>:<br/>", ++$results);
while($row = $result->fetch_row()) {
foreach($row as $cell) echo $cell, " ";
}
$result->close();
if($mysqli->more_results()) echo "<br/>";
}
} while($mysqli->next_result());
}
$mysqli->close();
7
Hier ist ein Beispiel dafür, wie man das mit mysql, mysqli und pdo macht:
http://www.joeyrivera.com/2009/using-mysql-stored-procedures-with-php-mysqlmysqlipdo/