- let sth =
- dbh#prepare_cached
- "select url, redirect, id, title, description,
- last_modified_date, css is not null
- from pages where hostid = ? and lower (url) = lower (?)" in
- sth#execute [Some hostid; Some page];
- (try
- (match sth#fetch1 () with
- | Some page' :: _ when page <> page' -> (* different case *)
- FPExternalRedirect page'
- | [ _; None; Some id; Some title; Some description;
- `Timestamp last_modified_date; `Bool has_page_css ] ->
- FPOK (id, title, description, last_modified_date,
- has_page_css)
- | _ :: Some redirect :: _ ->
- FPInternalRedirect redirect
- | xs -> failwith (Dbi.sdebug xs))
- with
- Not_found -> FPNotFound)
+ let rows = PGSQL(dbh)
+ "select url, redirect, id, title, description,
+ last_modified_date, css is not null
+ from pages
+ where hostid = $hostid and lower (url) = lower ($page)" in
+ match rows with
+ | [Some page', _, _, _, _, _, _]
+ when page <> page' -> (* different case *)
+ FPExternalRedirect page'
+ | [ _, None, id, title, description,
+ last_modified_date, has_page_css ] ->
+ let has_page_css = Option.get has_page_css in
+ FPOK (id, title, description, last_modified_date,
+ has_page_css)
+ | [_, Some redirect, _, _, _, _, _] ->
+ FPInternalRedirect redirect
+ | [] -> FPNotFound
+ | _ -> assert false