如何在AIR中有条件地参数化SQLite数据库? 例如,此查询:
//selectedID is the ID I want to select
query.text = "select * from table where id=@ID";
query.parameters['@ID']=selectedID;
但我希望where
语句仅在selectedID
大于0时才会显示。
我通常会做的是:
query.text = "select * from table"+(selectedID>0?" where id="+selectedID:'');
但是,我在LiveDocs上阅读了性能方面,最好使用参数。
是否可以对整个语句进行参数化,或者仅对值进行参数化? 或者这可能足够好了:
query.text = "select * from table"+(selectedID>0?" where id=@ID":'');
query.parameters['@ID']=selectedID;
答案 0 :(得分:0)
if (selectedID > 0)
{
query.text = .....
query.parameters['@ID'] = ...
}
else
{
query.text = .....
{