2015-06-22 32 views
1

我收到此錯誤時PARAMS未發現:的ColdFusion 9,採用CFSCRIPT查詢

參數「USER_ID和league_id」不是在參數列表中找到指定的

我在路過他們,我可以在放在函數內部的轉儲中查看它們。

這裏是怎麼回事在什麼...

ac = { 
    league_id = 1 
    ,user_id = 3 
    ,score1 = 14 
    ,score2 = 10 
}; 

這是引發錯誤轉儲....

writedump(Game.saveGame(argumentcollection = ac)); 

這裏是Game.saveGame功能

public any function saveGame(required numeric league_id, required numeric user_id, required numeric score1, required numeric score2) { 

    // writeDump(var=arguments); // this dump shows league_id & user_id... 
    var sql  = ''; 
    var tmp  = ''; 
    var r  = ''; 
    var q  = new query(); 

     q.setDatasource(this.dsn); 

     q.addParam(
       name = 'league_id' 
       ,value = '#val(arguments.league_id)#' 
       ,cfsqltype = 'CF_SQL_BIGINT' 
      ); 
     q.addParam(
       name = 'user_id' 
       ,value = '#val(arguments.user_id)#' 
       ,cfsqltype = 'CF_SQL_BIGINT' 
      ); 
     q.addParam(
       name = 'score1' 
       ,value = '#val(arguments.score1)#' 
       ,cfsqltype = 'CF_SQL_SMALLINT' 
      ); 
     q.addParam(
       name = 'score2' 
       ,value = '#val(arguments.score2)#' 
       ,cfsqltype = 'CF_SQL_SMALLINT' 
      ); 

     sql = 'INSERT INTO 
       games 
       (
        user_id 
        ,league_id 
        ,score1 
        ,score2 
       ) 
      VALUES 
       (
        :user_id 
        ,:league_id 
        ,:score1 
        ,:score2 
       ) 
     '; 

     tmp = q.execute(sql = sql); 

     r = tmp.getPrefix(q); 

     q.clearParams(); 

    return r; 

} 

這是一些問題的歷史 - 我在本地寫這篇文章,我的系統運行CF 11 .2 - 一切工作正常...但是,我不得不將它託管在CF 9.02服務器上,那就是當這個錯誤出現時 - 我不能在我的系統上重新創建它,但我確實記得以前看到過這個錯誤,但是對於我的生活,我不能找到我是如何解決它然後....

任何幫助或見解表示讚賞。

其他PARAMS 的Windows服務器,MySQL 5.5,Apache 2.2的

+0

我看不出有什麼不對您的代碼,但你可以也許會清理一些東西,不需要單獨設置每個「屬性」:http://blog.adamcameron.me/2014/01/using-querycfc-doesnt-have-to-be-drama.html –

+0

Thx Adam - 我會試試看,讓你知道 - 完全讚賞'更簡潔的語法。 – jpmyob

回答

1

亞當寫道:

I can't spot what's wrong with your code, but you could perhaps clean things up a bit. There's no need to set each "property" on the query separately: blog.adamcameron.me/2014/01/

繼序PARAM,而不是命名PARAM,過往則params的陣列中的冷凝格式,解決了我的問題。

我可能會玩的名稱屬性,看看它是否,正是..或者我可能只是作爲一個解決方案來處理。

現在,要改變我所有的腳本查詢!!!!! (祝他的文章提出了對谷歌的時候我一直在尋找進入query.cfc語法:(

感謝一大堆亞當!

+0

很酷。很高興幫助。 –