【发布时间】:2015-04-03 16:42:47
【问题描述】:
我必须使用相同的 mysqli 连接执行 2 个不同的查询。 我尝试在以下代码中使用 multi_query($query):
<?php
$re = $mysqli->query("SET CHARACTER SET 'utf8'");
$query = "CALL LDmodel_tree();CALL LDmodel_file()";
$mysqli->multi_query($query);
echo 'var fold = [];'."\n";
echo 'var file = [];'."\n";
$result = $mysqli->store_result();
while ($rsto = $result->fetch_row())
{
$y=0;$cart = array ();
do {$cart[$x][$y] = $rsto[$y]; $y++; } while ($y<4);
echo 'fold['.$x.'] = ['.$cart[$x][3].',"'.$cart[$x][1].'",'.$cart[$x][0].','.$cart[$x][2].'];'."\n"; /* ID, nome, livello, madre */
$x++;
}
$result->free();
echo 'var n_cart='.$x.';'."\n";
$result = $mysqli->next_result();
while ($rsto = $result->fetch_row())
{
$y=0;$cart = array ();
do {$cart[$x][$y] = $rsto[$y]; $y++; } while ($y<6);
echo 'file['.$x.'] = ['.$cart[$x][0].',"'.$cart[$x][1].'","'.$cart[$x][2].'",'.$cart[$x][3].','.$cart[$x][4].','.$cart[$x][5].'];'."\n";
$x++;
}
$result->free();
echo 'var n_file='.$nx.';'."\n";
?>
在第一次查询之后,它会触发这个错误:
在第 25 行的 E:\EasyPHP-5.3.9\www\MOD_tree.php 中调用非对象的成员函数 fetch_row()
请帮忙!!!
【问题讨论】: