Return to Snippet

Revision: 22885
at January 25, 2010 11:25 by ginoplusio


Initial Code
function duplicateRow($table,$primaryField,$primaryIDvalue) {
	// duplicate one record in a table
	// and return the id
	$fields = getCommaFields($table,$primaryField);
	$sql = "insert into $table ($fields) select $fields from $table where $primaryField='".mysql_real_escape($primaryIDvalue)."' limit 0,1";
	mysql_query($sql) or die(mysql_error().$sql);
	return mysql_insert_id();
}

Initial URL
http://www.barattalo.it/2010/01/25/10-php-usefull-functions-for-mysql-stuff/

Initial Description

                                

Initial Title
Duplicate one row in a MYSQL table through PHP

Initial Tags

                                

Initial Language
PHP