多个查询条件参数格式,哪种格式更简单方便?
格式1
var where={
'city|=':'010',
'logintime|>':14433343,
'nickname|like':'%xxxx%'
}
格式2
var where=[
['city','=','010'],
['logintime','>',144334343],
['nickname','like','%xxx%']
];
function buildQuery(where){
} 那种格式用起来更方便?
8 回复
我是这样做的
lib.dal(‘SELECT SQL_CALC_FOUND_ROWS a.id,a.title,b.name pcategories_id, b.id pcategories_id_value,’) (‘a.availability, a.order_processing, a.update_time’) (‘FROM products a’) (‘LEFT JOIN pcategories b ON b.id = a.pcategories_id’) (‘WHERE 1=1’) (‘AND a.pcategories_id=?’, opt.pcategories_idl) //设置null此条件将不生效 (‘AND (locate(?,a.id) > 0 OR locate(?,a.title) > 0)’, opt.search_value) (‘ORDER BY a.id DESC limit ?,?’, limit[0], limit[1]).query(done);