1 (* Copy a page from one host to another. Note that this only copies
2 * the text, not any images which may be present.
3 * $Id: copy_page.ml,v 1.4 2006/08/14 11:36:50 rich Exp $
5 * Usage: copy_page hostid url new_hostid new_url
8 module DB = Dbi_postgres
10 let dbh = DB.connect "cocanwiki"
12 let old_hostid = int_of_string Sys.argv.(1)
13 let old_url = Sys.argv.(2)
14 let new_hostid = int_of_string Sys.argv.(3)
15 let new_url = Sys.argv.(4)
18 let sth = dbh#prepare_cached
19 "select id from pages where hostid = ? and url = ?" in
20 sth#execute [`Int old_hostid; `String old_url];
21 let old_pageid = sth#fetch1int () in
23 let sth = dbh#prepare_cached
24 "insert into pages (url, title, description, keywords, noodp,
25 hostid, redirect, css)
26 select ? as url, title, description, keywords, noodp,
27 ? as hostid, redirect, css
30 sth#execute [`String new_url; `Int new_hostid; `Int old_pageid];
31 let new_pageid = sth#serial "pages_id_seq" in
33 let sth = dbh#prepare_cached
34 "insert into contents (pageid, ordering, sectionname, content,
36 select ? as pageid, ordering, sectionname, content, divname, jsgo
39 sth#execute [`Int new_pageid; `Int old_pageid];