0
我必须使用相同的mysqli连接执行2个不同的查询。 我试图用multi_query($查询),如下面的代码:Mysqli无法在同一连接上执行2个查询
<?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";
?>
第一查询后,它触发此错误:
调用一个成员函数fetch_row()一个非对象在E:\ EasyPHP-5.3.9 \ www \ MOD_tree.php on line25
请帮忙!!!
代码在改变: $结果= $ mysqli-> store_result(); 而($ RSTO = $ result-> fetch_row()) \t \t { \t ...... \t \t \t} \t $ result->免费(); 但没有改进。 我需要添加'more_result'语句吗? – 2015-04-03 17:30:17
这是否回答你的问题?如果是这样,您可以点击左侧的链接来接受此答案。 – 2015-04-03 17:32:22