q:=fmt.Sprintf("select honkid, donks.fileid, xid, name, description, url, media, local from donks join files on donks.fileid = files.fileid where honkid in (%s)",strings.Join(ids,","))
doordie(db,"delete from donks where honkid in (select honkid from honks where dt < ? and whofore = 0 and convoy not in (select convoy from honks where whofore = 2 or whofore = 3))",expdate)
doordie(db,"delete from honks where dt < ? and whofore = 0 and convoy not in (select convoy from honks where whofore = 2 or whofore = 3)",expdate)
}
doordie(db,"delete from files where fileid not in (select fileid from donks)")
for_,u:=rangeallusers(){
doordie(db,"delete from zonkers where userid = ? and wherefore = 'zonvoy' and zonkerid < (select zonkerid from zonkers where userid = ? and wherefore = 'zonvoy' order by zonkerid desc limit 1 offset 200)",u.UserID,u.UserID)
stmtHonkers=preparetodie(db,"select honkerid, userid, name, xid, flavor, combos from honkers where userid = ? and (flavor = 'sub' or flavor = 'peep' or flavor = 'unsub') order by name")
butnotthose:=" and convoy not in (select name from zonkers where userid = ? and wherefore = 'zonvoy' order by zonkerid desc limit 100)"
stmtOneXonk=preparetodie(db,selecthonks+"where honks.userid = ? and xid = ?")
stmtOneBonk=preparetodie(db,selecthonks+"where honks.userid = ? and xid = ? and what = 'bonk' and whofore = 2")
stmtPublicHonks=preparetodie(db,selecthonks+"where whofore = 2 and dt > ?"+limit)
stmtUserHonks=preparetodie(db,selecthonks+"where (whofore = 2 or whofore = ?) and username = ? and dt > ?"+limit)
stmtHonksForUser=preparetodie(db,selecthonks+"where honks.userid = ? and dt > ? and honker in (select xid from honkers where userid = ? and flavor = 'sub' and combos not like '% - %')"+butnotthose+limit)
stmtHonksForMe=preparetodie(db,selecthonks+"where honks.userid = ? and dt > ? and whofore = 1"+butnotthose+limit)
stmtHonksByHonker=preparetodie(db,selecthonks+"join honkers on (honkers.xid = honks.honker or honkers.xid = honks.oonker) where honks.userid = ? and honkers.name = ?"+butnotthose+limit)
stmtHonksByXonker=preparetodie(db,selecthonks+" where honks.userid = ? and (honker = ? or oonker = ?)"+butnotthose+limit)
stmtHonksByCombo=preparetodie(db,selecthonks+"join honkers on honkers.xid = honks.honker where honks.userid = ? and honkers.combos like ?"+butnotthose+limit)
stmtHonksBySearch=preparetodie(db,selecthonks+"where honks.userid = ? and noise like ?"+limit)
stmtHonksByConvoy=preparetodie(db,selecthonks+"where (honks.userid = ? or (? = -1 and whofore = 2)) and convoy = ?"+limit)
stmtHonksByOntology=preparetodie(db,selecthonks+"join onts on honks.honkid = onts.honkid where onts.ontology = ? and (honks.userid = ? or (? = -1 and honks.whofore = 2))"+limit)
stmtGetDoovers=preparetodie(db,"select dooverid, dt from doovers")
stmtLoadDoover=preparetodie(db,"select tries, username, rcpt, msg from doovers where dooverid = ?")
stmtZapDoover=preparetodie(db,"delete from doovers where dooverid = ?")
stmtThumbBiters=preparetodie(db,"select userid, name, wherefore from zonkers where (wherefore = 'zonker' or wherefore = 'zomain' or wherefore = 'zord' or wherefore = 'zilence')")
stmtFindZonk=preparetodie(db,"select zonkerid from zonkers where userid = ? and name = ? and wherefore = 'zonk'")
stmtGetZonkers=preparetodie(db,"select zonkerid, name, wherefore from zonkers where userid = ? and wherefore <> 'zonk'")
stmtSaveZonker=preparetodie(db,"insert into zonkers (userid, name, wherefore) values (?, ?, ?)")
stmtGetXonker=preparetodie(db,"select info from xonkers where name = ? and flavor = ?")
stmtSaveXonker=preparetodie(db,"insert into xonkers (name, info, flavor) values (?, ?, ?)")
stmtDeleteXonker=preparetodie(db,"delete from xonkers where name = ? and flavor = ?")
stmtRecentHonkers=preparetodie(db,"select distinct(honker) from honks where userid = ? and honker not in (select xid from honkers where userid = ? and flavor = 'sub') order by honkid desc limit 100")
stmtUpdateFlags=preparetodie(db,"update honks set flags = flags | ? where honkid = ?")
stmtClearFlags=preparetodie(db,"update honks set flags = flags & ~ ? where honkid = ?")
stmtSelectOnts=preparetodie(db,"select distinct(ontology) from onts join honks on onts.honkid = honks.honkid where (honks.userid = ? or honks.whofore = 2)")