function anonymous_publishing_update_7004 in Anonymous Publishing 7
Add field 'uid' to {anonymous_publishing_realname}.
File
- ./
anonymous_publishing.install, line 440 - Install and uninstall hooks.
Code
function anonymous_publishing_update_7004() {
$uid = array(
'description' => '{users}.uid reference',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
);
db_add_field('anonymous_publishing_realname', 'uid', $uid);
$rows = db_query("SELECT rnid, realname FROM {anonymous_publishing_realname}")
->fetchAll(PDO::FETCH_ASSOC);
foreach ($rows as $row) {
$user = user_load_by_name($row['realname']);
$uid = $user->uid;
db_update('anonymous_publishing_realname')
->fields(array(
'uid' => $uid,
))
->condition('rnid', $row['rnid'])
->execute();
}
db_drop_field('anonymous_publishing_realname', 'realname');
}