[Fusionforge-commits] r8508 - trunk/gforge/utils/fixscripts

Roland Mas lolando at libremir.placard.fr.eu.org
Thu Dec 10 14:18:17 CET 2009


Author: lolando
Date: 2009-12-10 14:18:17 +0100 (Thu, 10 Dec 2009)
New Revision: 8508

Modified:
   trunk/gforge/utils/fixscripts/fix_image_data.php
   trunk/gforge/utils/fixscripts/upgrade_bug_data.php
   trunk/gforge/utils/fixscripts/upgrade_filerelease_data.php
   trunk/gforge/utils/fixscripts/upgrade_forum_data.php
   trunk/gforge/utils/fixscripts/upgrade_task_data.php
Log:
db_query_params for fixscripts

Modified: trunk/gforge/utils/fixscripts/fix_image_data.php
===================================================================
--- trunk/gforge/utils/fixscripts/fix_image_data.php	2009-12-10 13:18:03 UTC (rev 8507)
+++ trunk/gforge/utils/fixscripts/fix_image_data.php	2009-12-10 13:18:17 UTC (rev 8508)
@@ -15,7 +15,7 @@
         exit_permission_denied();
 }
 
-$res=db_query("SELECT id,bin_data FROM db_images ORDER BY id ASC",50,$offset);
+$res=db_query_params('SELECT id,bin_data FROM db_images ORDER BY id ASC',array(),50,$offset);
 
 $rows=db_numrows($res);
 
@@ -26,11 +26,18 @@
 	echo "<br />fixing: ".db_result($res,$i,'id');
 
 	$data=addslashes(base64_encode(db_result($res,$i,'bin_data')));
-	$res2=db_query("UPDATE db_images SET bin_data='$data' WHERE id='". db_result($res,$i,'id') ."'");
+	$res2=db_query_params('UPDATE db_images SET bin_data=$1 WHERE id=$2',
+			      array ($data,
+				     db_result($res,$i,'id')));
 	if (!$res2 || db_affected_rows($res2) < 1) {
 		echo db_error();
 	}
 
 }
 
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
 ?>

Modified: trunk/gforge/utils/fixscripts/upgrade_bug_data.php
===================================================================
--- trunk/gforge/utils/fixscripts/upgrade_bug_data.php	2009-12-10 13:18:03 UTC (rev 8507)
+++ trunk/gforge/utils/fixscripts/upgrade_bug_data.php	2009-12-10 13:18:17 UTC (rev 8508)
@@ -31,26 +31,39 @@
 		//insert a default bug dependency
 	*/
 
-	$res2=db_query("SELECT * FROM bug_bug_dependencies WHERE bug_id='". db_result($result,$i,'bug_id') ."'");
+	$res2=db_query_params('SELECT * FROM bug_bug_dependencies WHERE bug_id=$1',
+			      array (db_result($result,$i,'bug_id'))) ;
 	$rows2=db_numrows($res2);
 	if ($rows2 < 1) {
-		db_query ("INSERT INTO bug_bug_dependencies VALUES ('','". db_result($result,$i,'bug_id') ."','100')");
+		db_query_params ('INSERT INTO bug_bug_dependencies VALUES ($1,$2,100)',
+				 array ('',
+					db_result($result,$i,'bug_id'))) ;
 	} else if ($rows2 > 1) {
-		db_query ("DELETE FROM bug_bug_dependencies WHERE bug_id='". db_result($result,$i,'bug_id') ."' AND is_dependent_on_bug_id='100'");
+		db_query_params ('DELETE FROM bug_bug_dependencies WHERE bug_id=$1 AND is_dependent_on_bug_id=100',
+				 array (db_result($result,$i,'bug_id'))) ;
 	}
 
 	/*
 		//insert a default task dependency
 	*/
 
-	$res2=db_query("SELECT * FROM bug_task_dependencies WHERE bug_id='". db_result($result,$i,'bug_id') ."'");
+	$res2=db_query_params('SELECT * FROM bug_task_dependencies WHERE bug_id=$1',
+			      array (db_result($result,$i,'bug_id'))) ;
 	$rows2=db_numrows($res2);
 	if ($rows2 < 1) {
-		db_query ("INSERT INTO bug_task_dependencies VALUES ('','". db_result($result,$i,'bug_id') ."','100')");
+		db_query_params ('INSERT INTO bug_task_dependencies VALUES ($1, $2, 100)',
+				 array ('',
+					db_result($result,$i,'bug_id'))) ;
 	} else if ($rows2 > 1) {
-		db_query ("DELETE FROM bug_task_dependencies WHERE bug_id='". db_result($result,$i,'bug_id') ."' AND is_dependent_on_task_id='100'");
+		db_query_params ('DELETE FROM bug_task_dependencies WHERE bug_id=$1 AND is_dependent_on_task_id=100',
+				 array (db_result($result,$i,'bug_id'))) ;
 	}
 
 }
 
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
 ?>

Modified: trunk/gforge/utils/fixscripts/upgrade_filerelease_data.php
===================================================================
--- trunk/gforge/utils/fixscripts/upgrade_filerelease_data.php	2009-12-10 13:18:03 UTC (rev 8507)
+++ trunk/gforge/utils/fixscripts/upgrade_filerelease_data.php	2009-12-10 13:18:17 UTC (rev 8508)
@@ -43,8 +43,9 @@
 	/*
 		Get the files from the old system for this release
 	*/
-	$res2=db_query("SELECT * FROM filerelease ".
-		"WHERE filemodule_id='". db_result($result,$i,'package_id') ."' AND release_version='". db_result($result,$i,'name') ."'");
+	$res2=db_query_params ('SELECT * FROM filerelease WHERE filemodule_id=$1 AND release_version=$2',
+			       array (db_result($result,$i,'package_id'),
+				      db_result($result,$i,'name'))) ;
 
 	$rows2=db_numrows($res2);
 	//echo db_error();
@@ -53,7 +54,8 @@
 			no matches for this release
 		*/
 		echo "\n<br />Warning - deleting release!";
-		db_query ("DELETE FROM frs_release WHERE release_id='". db_result($result,$i,'release_id') ."'");
+		db_query_params ('DELETE FROM frs_release WHERE release_id=$1',
+				 array (db_result($result,$i,'release_id'))) ;
 	} else {
 		$release_id=db_result($result,$i,'release_id');
 
@@ -61,25 +63,37 @@
 			set the change notes and release time for this release 
 			based on any given file from the release in the old system
 		*/
-		db_query ("UPDATE frs_release SET notes='". addslashes(db_result($res2,0,'text_notes')) ."',".
-			"changes='". addslashes(db_result($res2,0,'text_changes')) ."', ".
-			"preformatted='". db_result($res2,0,'text_format') ."', ".
-			"released_by='". db_result($res2,0,'user_id') ."', ".
-			"release_date='". db_result($res2,0,'release_time') ."' ".
-			"WHERE release_id='$release_id'");
+		db_query_params ('UPDATE frs_release SET notes=$1,changes=$2,preformatted=$3,released_by=$4,release_date=$5 WHERE release_id=$6',
+				 array (db_result($res2,0,'text_notes'),
+					db_result($res2,0,'text_changes'),
+					db_result($res2,0,'text_format'),
+					db_result($res2,0,'user_id'),
+					db_result($res2,0,'release_time'),
+					$release_id)) ;
 
 		echo "\n<br />Update Release: $release_id :: ".db_error();
 
 		for ($f=0; $f<$rows2; $f++) {
-			/*
-				move each of the files from the old system to the new
-			*/
-			db_query("INSERT INTO frs_file (file_id,filename,release_id,processor_id,release_time,file_size,post_date,type_id) VALUES ".
-				"('". db_result($res2,$f,'filerelease_id') ."','". db_result($res2,$f,'filename') ."','$release_id',".
-				"'9999','". db_result($res2,$f,'release_time') ."','". db_result($res2,$f,'file_size') ."','". db_result($res2,$f,'post_time') ."','9999')");
+		  /*
+		   move each of the files from the old system to the new
+		  */
+		  db_query_params ('INSERT INTO frs_file (file_id,filename,release_id,processor_id,release_time,file_size,post_date,type_id) VALUES ($1,$2,$3,$4,$5,$6,$7,$8)',
+				   array (db_result($res2,$f,'filerelease_id'),
+					  db_result($res2,$f,'filename'),
+					  $release_id,
+					  9999,
+					  db_result($res2,$f,'release_time'),
+					  db_result($res2,$f,'file_size'),
+					  db_result($res2,$f,'post_time'),
+					  9999)) ;
 			echo "\n<br />File: ". db_result($res2,$f,'filerelease_id') ." :: ".db_error();
 		}
 	}
 }
 
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
 ?>

Modified: trunk/gforge/utils/fixscripts/upgrade_forum_data.php
===================================================================
--- trunk/gforge/utils/fixscripts/upgrade_forum_data.php	2009-12-10 13:18:03 UTC (rev 8507)
+++ trunk/gforge/utils/fixscripts/upgrade_forum_data.php	2009-12-10 13:18:17 UTC (rev 8508)
@@ -19,7 +19,7 @@
 session_require(array('group'=>'1','admin_flags'=>'A'));
 
 //get all the tasks
-$result=db_query("SELECT msg_id FROM forum ORDER BY msg_id ASC",10000,$z);
+$result=db_query_params('SELECT msg_id FROM forum ORDER BY msg_id ASC', array(), 10000, $z);
 $rows=db_numrows($result);
 echo db_error();
 echo "\nRows: $rows\n";
@@ -33,7 +33,8 @@
 		//insert a default bug dependency
 	*/
 
-	$res2=db_query("SELECT count(*) FROM forum WHERE is_followup_to='". db_result($result,$i,'msg_id') ."'");
+	$res2=db_query_params('SELECT count(*) FROM forum WHERE is_followup_to=$1',
+			      array (db_result($result,$i,'msg_id'))) ;
 	$rows2=db_numrows($res2);
 	if (db_result($res2,0,0) < 1) {
 		// don't do anything
@@ -41,7 +42,8 @@
 		//echo db_error();
 	} else {
 		$counter++;
-		db_query ("UPDATE forum SET has_followups='1' WHERE msg_id='". db_result($result,$i,'msg_id') ."'");
+		db_query_params ('UPDATE forum SET has_followups=1 WHERE msg_id=$1',
+				 array (db_result($result,$i,'msg_id'))) ;
 	}
 }
 
@@ -49,4 +51,9 @@
 echo "\n\nSkipped: $counter2";
 flush();
 
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
 ?>

Modified: trunk/gforge/utils/fixscripts/upgrade_task_data.php
===================================================================
--- trunk/gforge/utils/fixscripts/upgrade_task_data.php	2009-12-10 13:18:03 UTC (rev 8507)
+++ trunk/gforge/utils/fixscripts/upgrade_task_data.php	2009-12-10 13:18:17 UTC (rev 8508)
@@ -31,26 +31,39 @@
 		//insert a default dependency
 	*/
 
-	$res2=db_query("SELECT * FROM project_dependencies WHERE project_task_id='". db_result($result,$i,'project_task_id') ."'");
+	$res2=db_query_params('SELECT * FROM project_dependencies WHERE project_task_id=$1',
+			      array (db_result($result,$i,'project_task_id'))) ;
 	$rows2=db_numrows($res2);
 	if ($rows2 < 1) {
-		db_query ("INSERT INTO project_dependencies VALUES ('','". db_result($result,$i,'project_task_id') ."','100')");
+		db_query_params ('INSERT INTO project_dependencies VALUES ($1,$2,100)',
+				 array ('',
+					db_result($result,$i,'project_task_id'))) ;
 	} else if ($rows2 > 1) {
-		db_query ("DELETE FROM project_dependencies WHERE project_task_id='". db_result($result,$i,'project_task_id') ."' AND is_dependent_on_task_id='100'");
+		db_query_params ('DELETE FROM project_dependencies WHERE project_task_id=$1 AND is_dependent_on_task_id=100',
+				 array (db_result($result,$i,'project_task_id'))) ;
 	}
 
 	/*
 		//insert a default assignee 
 	*/
 
-	$res2=db_query("SELECT * FROM project_assigned_to WHERE project_task_id='". db_result($result,$i,'project_task_id') ."'");
+	$res2=db_query_params('SELECT * FROM project_assigned_to WHERE project_task_id=$1',
+			      array (db_result($result,$i,'project_task_id'))) ;
 	$rows2=db_numrows($res2);
 	if ($rows2 < 1) {
-		db_query ("INSERT INTO project_assigned_to VALUES ('','". db_result($result,$i,'project_task_id') ."','100')");
+		db_query_params ('INSERT INTO project_assigned_to VALUES ($1,$2,100)',
+				 array ('',
+					db_result($result,$i,'project_task_id'))) ;
 	} else if ($rows2 > 1) {
-		db_query ("DELETE FROM project_assigned_to WHERE project_task_id='". db_result($result,$i,'project_task_id') ."' AND assigned_to_id='100'");
+		db_query_params ('DELETE FROM project_assigned_to WHERE project_task_id=$1 AND assigned_to_id=100',
+				 array (db_result($result,$i,'project_task_id'))) ;
 	}
 
 }
 
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
 ?>




More information about the Fusionforge-commits mailing list