试图从PHP multi_query获得价值 [英] Trying to get value from PHP multi_query
本文介绍了试图从PHP multi_query获得价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在这个问题上停留了一段时间,正在寻找有用的建议.
I'm stuck on this problem for a while now and looking for helpful suggestions.
$resultset = $connection->multi_query($sql);
pseudo:
IF $resultset > 0 (--> if the sql query returned at least one result) {
// do something
}
现在问题出在伪部件上,我尝试执行以下操作:
now the problem is with the pseudo part, i have tried to the follows:
if($resultset > 0) // takes no effect
if($resultset->num_rows > 0) // Notice: Trying to get property of non-object
我必须使用multi_query,所以mysqli_query/mysqli_fetch_array不是解决方案
I have to use multi_query so mysqli_query/mysqli_fetch_array is not a solution
感谢您的提示....
推荐答案
请尝试:
if($connection->multi_query($sql))
{
//sample query taken from php manual, see link below
do {
/* store first result set */
if ($result = $connection->store_result()) {
while ($row = $result->fetch_row()) {
printf("%s\n", $row[0]);
}
$result->free();
}
/* print divider */
if ($connection->more_results()) {
printf("-----------------\n");
}
} while ($connection->next_result());
}
else
{
//handle error
echo mysqli_error ( $connection );
}
如果您查看多重查询的文档(请在此处 ),您会看到该函数返回boolean
.
If you check out the documentation of multi query (here), you will see that the function returns a boolean
.
源代码也来自 php手册.
这篇关于试图从PHP multi_query获得价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文