如何在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;
if (selectedID > 0)
{
query.text = .....
query.parameters['@ID'] = ...
}
else
{
query.text = .....
{