0
我正在嘗試tfusion在ColdFusion中cfscript迭代通過變量的請求集合並做一些評估,我可以在PHP中輕鬆完成,但運行時轉換爲coldfusion cfscript ,因爲它似乎我不能建立通過動態評估迭代通過url請求收集變量
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語句
PHP也試圖改變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#) {
這裏是靜態的ColdFusion不,我希望我可以有問題
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 ";}
}
做任何幫助將非常感激迭代
*我已經試過了,出錯了*。什麼是錯誤信息?僅供參考:「URL」範圍是一個結構。您可以使用關聯數組表示法動態訪問這些值:即'url [「someFixedName」&counterVariable]'。 – Leigh
..這同樣適用於任何結構。 – Leigh