複数のクエリで同じmysqlリソースを使用できますか?mysqlのリンクリソースが低温化中
$queries=array($q1, $q2);
$link=mysql_connect(...);
mysql_select_db(...);
for($i = 0; $i < count($queries); $i++) {
echo "Link is of type " . gettype($link) . "<br />";
if(is_resource($link)) {
mysql_query($queries[$i], $link);
} else {
echo "Did not execute query. <br/>";
}
}
disconnect($link);
出力:
link is of type resource
Successfully executed query
link is of type resource
Did not execute query.
編集:私は最初のクエリが実行されることを出力から指摘したかったが、2番目にはありません。その間に、リンクに変更はありません。どのようにクエリを実行するかは重要ではありません(IMHO)。
EDIT 2:以下の私の正確なコード:
$link = mysql_connect("localhost", ........);
mysql_select_db(....);
for ($row = 0; $row < $numRows; $row++) {
if (($query = buildQuery($mainArr, $rowArr, $row)) === null) {
echo "Error - could not build query. <br />";
return;
}
echo "Link is of type " . gettype($link) . "<br />";
if (is_resource($link)) {
if ((mysql_query($query, $link))) {
if($debug) {
echo "Successfully executed query <br />";
}
} else {
if ($debug) {
echo "This comes up when row is " . $row . "<br />";
echo "Link is of type " . gettype($link) . "<br />";
echo "Datawrite failed - " . $query . "<br />";
echo "the official line is " . mysql_error($link) . "<br />";
}
}
} else {
echo "Did not execute query <br />";
}
}
disconnect($link);
2番目のクエリの結果はどうなりますか? –
forループで$ querriesのスペルが間違っています。 $クエリでなければなりません。 –
あなたはmysqlリソースを参照していますか? '$リンク'? – Dirk