現在、次の構造を使用して、複数のパラメーターを mysqli クエリにバインドすることに対処する必要があります。
if ($words_total == 1)
{
$statement -> bind_param("s", $words[0]);
}
else if ($words_total == 2)
{
$statement -> bind_param("ss", $words[0], $words[1]);
}
else if ($words_total == 3)
{
$statement -> bind_param("sss", $words[0], $words[1], $words[2]);
}
//and so on....
以下のコードを使用して疑問符の数を計算し、それをクエリに挿入します。
$marks = "";
for($i = 1; $i<=$words_total; $i++) {
if ($i == $words_total)
{
$marks .= "?";
}
else
{
$marks .= "?,";
}
}
私の質問は、動的に必要なだけ多くの入力をクエリに処理する方法が必要です。ハードコーディングは、bind_param()
これを処理するための本当に悪い方法のようです。
PHPバージョン5.4.10を使用しています