results_patientalerts = db.GqlQuery("SELECT * FROM PatientAlerts WHERE patientinfo_ID=" + data_key + " AND alert_type!=3")
patientinfo_ID is db.IntegerPrope开发者_如何转开发rty()
data_key is key which i got it from URL....
Inserting query arguments inline is generally a bad idea. A much better way is to let the db
library do this for you:
results_patientalerts = db.GqlQuery("SELECT * FROM PatientAlerts WHERE patientinfo_ID = :1 AND alert_type != :2", data_key, 3)
By querying the database this way you avoid any query escaping, quoting and/or formatting issues, since it's done automatically.
As you didn't say what exactly doesn't work in this query I cannot say what the problem is with it, but it could be some sort of an issue related to the above.
精彩评论