【发布时间】:2015-10-09 10:44:01
【问题描述】:
我想使用来自不同查询的获取结果作为 mysql 过程的输入。为此,我编写了以下代码:
$link = mysqli_connect("localhost","root","","localhost") or die("Error " . mysqli_error($link));
if (mysqli_connect_errno())
{
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query_level1 = "select id,name...from table1; ";
$query_level1 = "select id,address...from table2;";
if ($res_level1=mysqli_query($link,$query_level1))
{
while ($row_l1 = mysqli_fetch_row($res_level1))
{
foreach($row_l1 as $key)
{
$parent_l1 = explode(';',$key);
if ( 1 <count($parent_l1))
{
for ($i = 0;$i < count($parent_l1);$i++)
{
$res_level2=mysqli_query($link,$query_level2);
-----here fatch the result of $res_level2 into $child array with another for loop
after this step call a procedure:
if (!$link->query("call update_from_level1(" . $child[$k] . "," . $parent_l1[$i] ")" ))
{
echo "update_from_level1 : (" . $link->errno . ") ";
}
}
}
}
}
}
如果我获取$query_level1 的结果,它可以正常工作;但是当我获取$query_level2 的结果时,它不起作用。你能帮我解决问题吗?
【问题讨论】:
-
据我从您的代码中可以看出,您没有为您的
#query_level2分配任何查询字符串。 -
我没有在您的代码中得到 query_level2,只需将您的第二个查询变量名称更改为 level2 然后检查
-
我没有写整个查询,
-
$query_level1 = "从 map_node 中选择 id、名称、描述、type_id、url、icon_id、backend_id;"
-
$query_level2 = "SELECT id, name, description, org_id, business_criticity, move2production, finalclass FROM functionalci ; "
标签: php mysql for-loop stored-procedures