rem:  var unquote = new RegExp("\'"); unquote.global = true; var qarr = query.replace(unquote, "''").split(" "); 
add:  var where = "select AV_TEXT.TEXT_ID, AV_SITE.SITE_ALIAS from AV_TEXT, AV_SITE where "+ "AV_TEXT.TEXT_F_SITE = AV_SITE.SITE_ID and "+ "AV_TEXT.TEXT_ISONLINE > 0 and "; for (var i in qarr) { where += "(AV_TEXT.TEXT_RAWCONTENT like '%"+qarr[i].toLowerCase()+"%') " if (i < qarr.length-1) where += "and "; }  if (sid) where += "and AV_SITE.SITE_ID = "+sid+" "; else where += "and AV_SITE.SITE_ISONLINE > 0 "; where += "order by AV_TEXT.TEXT_CREATETIME desc"; 
context: function searchSites (query, sid) {    // reuse search result container if it already exists    var result = result = new Array();    // break up search string    var unquote = new RegExp("\'");    unquote.global = true;    var qarr = query.replace(unquote, "''").split(" ");    // construct query    var where = "select AV_TEXT.TEXT_ID, AV_SITE.SITE_ALIAS from AV_TEXT, AV_SITE where "+                "AV_TEXT.TEXT_F_SITE = AV_SITE.SITE_ID and "+                "AV_TEXT.TEXT_ISONLINE > 0 and ";    for (var i in qarr) {        where += "(AV_TEXT.TEXT_RAWCONTENT like '%"+qarr[i].toLowerCase()+"%') "        if (i < qarr.length-1)            where += "and ";    }    // search only in the specified site    if (sid)        where += "and AV_SITE.SITE_ID = "+sid+" ";    else        where += "and AV_SITE.SITE_ISONLINE > 0 ";    where += "order by AV_TEXT.TEXT_CREATETIME desc";    // writeln (where);    var dbcon = getDBConnection ("antville");    var dbres = dbcon.executeRetrieval(where);    if (dbres) {       while (dbres.next()) {          var item = new Object();          item.sid = dbres.getColumnItem (1).toString();          item.sitealias = dbres.getColumnItem (2);          result[result.length] = item;       }    }    dbres.release();    return result;}
meta: 993	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/993/3aa1a0c1a5754a08607669a8b5d4a0ccab129a93/objectFunctions.js/clean/code/Root/objectFunctions.js