Return to Snippet

Revision: 48345
at June 29, 2011 07:40 by hugosolar


Initial Code
function update_tables() {
	global $wpdb;
	for ($x=0;$x<=216;$x++): //limit for to the last blog_id created
		$table='wp_'.$x.'_options';
		$existe= $wpdb->get_results('SELECT * FROM '.$table.'');

		if ($existe)
			foreach($existe as $entry):
				if ($entry->option_name=='siteurl') {
					$siteurl=str_replace('my.old.url','my.new.url',$entry->option_value);
					$wpdb->update( $table, array('option_value'=>$siteurl), array('option_id' => $entry->option_id) );
				}
				if ($entry->option_name=='home') {
					$home=$entry->option_value;
					$home=str_replace('my.old.url','my.new.url',$entry->option_value);
				
					$wpdb->update( $table, array('option_value'=>$home), array('option_id' => $entry->option_id) );
				}
			
			
			endforeach;
	endfor;
}

add_action('init','update_tables');

Initial URL
http://www.hugosolar.net

Initial Description


Initial Title
Replace fields siteurl and home in wp_options tables in a wordpress multisite

Initial Tags
wordpress, update

Initial Language
PHP