File: 20021213-2-doc_data-migrate.php

package info (click to toggle)
fusionforge 5.3.2%2B20141104-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 60,472 kB
  • sloc: php: 271,846; sql: 36,817; python: 14,575; perl: 6,406; sh: 5,980; xml: 4,294; pascal: 1,411; makefile: 911; cpp: 52; awk: 27
file content (51 lines) | stat: -rw-r--r-- 1,051 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#! /usr/bin/php
<?php

/**
 * Data migration for the doc_manager - between pre6 and pre7
 *
 * Copyright 2002 (c) GFORGE LLC
 */

require_once dirname(__FILE__).'/../www/env.inc.php';
require_once $gfcommon.'include/pre.php';

@ini_set('memory_limit', '128M');

// drop and recreate page cache
//
//SELECT * FROM doc_data WHERE filename is null;
db_begin();

$res=db_query_params ('SELECT * FROM doc_data WHERE filename IS NULL',
			array()) ;

if (!$res) {
	echo db_error();
	db_rollback();
	exit();
}
$rows=db_numrows($res);

for ($i=0; $i<$rows; $i++) {
	$res2 = db_query_params ('UPDATE doc_data SET data=$1,filename=$2,filetype=$3 WHERE docid=$4',
				 array (base64_encode( util_unconvert_htmlspecialchars( db_result($res,$i,'data'))),
					'file'.db_result($res,$i,'docid').'.html',
					'text/html',
					db_result($res,$i,'docid'))) ;
	if (!$res2 || db_affected_rows($res2) < 1) {
		echo 'DB ERROR'.db_error();
		db_rollback();
		exit;
	}
}

db_commit();
echo "SUCCESS\n";

// Local Variables:
// mode: php
// c-file-style: "bsd"
// End:

?>