Sto cercando di parametrizzare una query che sta attualmente lavorando ed è maturo per un attacco SQL injection:interrogazione Parametrizzazione ORM con cui nella clausola
qryAwards = ORMExecuteQuery(
"from Award where awardID in (#form.deleteAwardList#) and Game.Season.User.userID=:uid",
{uid=session.userID}
);
if(not isNull(qryAwards) and arrayLen(qryAwards)){
for(i in qryAwards){
entityDelete(i);
}
}
Ho provato questo, avendo il parametro senza virgolette singole:
qryAwards = ORMExecuteQuery(
"from Award where awardID in (:awardList) and Game.Season.User.userID=:uid",
{awardList=form.deleteAwardList, uid=session.userID}
);
Continuo a ricevere il seguente errore:
The value 117,118 cannot be converted to a number.
E questo, con il parametro racchiuso tra virgolette singole:
qryAwards = ORMExecuteQuery(
"from Award where awardID in (':awardList') and Game.Season.User.userID=:uid",
{awardList=form.deleteAwardList, uid=session.userID}
);
me ottiene il seguente errore:
Invalid parameters specified for the query.
Grazie, funziona! – TekiusFanatikus
Per pura curiosità, questo approccio sfugge agli apostrofi? –
Dovrebbe. Ogni volta che si parametrizzano i dati come questi caratteri speciali, viene eseguito l'escape, proprio come in 'cfparam'. Inoltre, non puoi usare 'cfqueryparam' wtih' ORMExecuteQuery() '. Utilizzando i parametri come è, è come usare 'cfqueryparam' –