私がcoldfusion cfscriptでやろうとしているのは、変数のリクエストコレクションを繰り返し処理し、PHPで簡単に実行できる評価を行うことですが、動的なifステートメントを作成できないように見えるため、coldfusion cfscriptへの変換で問題が発生しています
PHP
for ( $i=0 ; $i<count($aColumns) ; $i++ )
{
if ( $_GET['bSearchable_'.$i] == "true" && $_GET['sSearch_'.$i] != '' )
{
//If there was no where clause
if ( $sWhere == "" )
{
$sWhere = "WHERE ";
}
else
{
$sWhere .= " AND ";
}
私はこれを試しましたが、エラーになりました
for (i=1; i<= iColumnsLen; i++) {
if (rc.bSearchable_&i EQ true and rc.sSearch&i NEQ '') {
if ( sWhere EQ "" )
{ sWhere = " WHERE "; }
else
{ sWhere &= " AND ";}
}
}
また、if文の行をこれに変更しようとしましたが、同じです
if (rc.bSearchable_+i EQ true and rc.sSearch+i NEQ '') {
最後に、文字列を作成してそれを使用しようとしましたが、うまくいかないことはわかっていましたが、試してみようと思いました.varをブール値に変換できませんでした.
for (i=1; i<= iColumnsLen; i++) {
var iterator = "rc.bSearchable_"&i&" EQ true and rc.sSearch_"&i&" NEQ ''";
if (#iterator#) {
これは、私が問題を抱えてやりたいと思っている反復なしの静的コールドフュージョンです
if (rc.bSearchable_1 EQ true and rc.sSearch_1 NEQ '') {
if ( sWhere EQ "" )
{ sWhere = " WHERE "; }
else
{ sWhere &= " AND ";}
}
if (rc.bSearchable_2 EQ true and rc.sSearch_2 NEQ '') {
if ( sWhere EQ "" )
{ sWhere = " WHERE "; }
else
{ sWhere &= " AND ";}
}
if (rc.bSearchable_3 EQ true and rc.sSearch_3 NEQ '') {
if ( sWhere EQ "" )
{ sWhere = " WHERE "; }
else
{ sWhere &= " AND ";}
}
どんな助けも大いに義務付けられます