+let exec ~(dbd:Mysql.dbd) ?rating (n,from,where) =
+ let from = String.concat ", " from in
+ let where = String.concat " and " where in
+ let query =
+ match rating with
+ | None -> sprintf "select table0.source from %s where %s" from where
+ | Some `Hits ->
+ sprintf
+ ("select table0.source from %s, hits where %s
+ and table0.source = hits.source order by hits.no desc")
+ from where
+ in
+(* prerr_endline query; *)
+ let result = Mysql.exec dbd query in
+ Mysql.map result
+ (fun row -> match row.(0) with Some s -> s | _ -> assert false)
+