I just tested this and it works.
<?php
function toCall(){
global $wpdb;
$togos = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE meta_key='_nelioefi_url'");
return $togos;
}
foreach (toCall() as $go) {
global $wpdb;
$wpdb->update(
$wpdb->postmeta,
array(
'meta_key' => 'external_thumbnail', // string
// 'column2' => 'value2' // integer (number)
),
array( 'meta_id' => $go->meta_id )
);
}; ?>
You can call the foreach loop somewhere in a file, just make sure you have enough memory 🙂
EDIT You can put everything in one function:
function toCall(){
global $wpdb;
$togos = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE meta_key='_nelioefi_url'");
foreach ($togos as $go) {
global $wpdb;
$wpdb->update(
$wpdb->postmeta,
array(
'meta_key' => 'external_thumbnail', // string
// 'column2' => 'value2' // integer (number)
),
array( 'meta_id' => $go->meta_id )
);
};
} ?>
Then you can call the toCall()
method anywhere you want in a template, or otherwise.
NB: The changes are irreversible. So, make sure you have backups.