[英]Return variable from stored procedure MySQL
How can I return a declared string like ( lastInsertId )
from my MySQL stored procedure and out? 如何从MySQL存储过程中返回声明的字符串,例如
( lastInsertId )
? It's really annoying I can't return error messegts, complate messages and more out to my code in PHP5. 我无法在PHP5中将错误信息,错误消息和更多内容返回我的代码,这真是令人讨厌。
I hope somebody can help me here, I have search Google around without luck :( 我希望有人可以在这里为我提供帮助,但我在搜索Google时没有碰到运气:(
Thanks to everybody. 感谢大家。
The function you need is mysqli->insert_id 您需要的功能是mysqli-> insert_id
This is the example that php.net provides, I think this function is what you are looking for: 这是php.net提供的示例,我认为您正在寻找该功能:
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$mysqli->query("CREATE TABLE myCity LIKE City");
$query = "INSERT INTO myCity VALUES (NULL, 'Stuttgart', 'DEU', 'Stuttgart', 617000)";
$mysqli->query($query);
printf ("New Record has id %d.\n", $mysqli->insert_id);
/* drop table */
$mysqli->query("DROP TABLE myCity");
/* close connection */
$mysqli->close();
?>
You'll find more info here: php.net: mysqli->inert_id - Manual 您可以在此处找到更多信息: php.net:mysqli-> inert_id-手册
If you need more help using it I'll be happy to help you. 如果您需要更多帮助,我们将竭诚为您服务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.