21$sql = "SELECT m AS id, z.initid AS initid FROM (SELECT min(id) AS m, initid, count(initid) AS c FROM docread WHERE locked != -1 AND doctype != 'T' GROUP BY docread.initid) AS z where z.c > 1";
29print sprintf("Fixing mutiple alive revision for (initid='%s', id='%s')\n", $el['initid'], $el['id']);
30 $res = array();
31$sql = sprintf("UPDATE doc SET locked = -1 WHERE initid = %s AND id = %s AND locked != -1 AND doctype != 'T'", pg_escape_string($el['initid']) , pg_escape_string($el['id']));