function invite_update_8 in Invite 6.2
Same name and namespace in other branches
- 5.2 invite.install \invite_update_8()
- 5 invite.install \invite_update_8()
- 7.2 invite.install \invite_update_8()
Change message to a generic data column and convert existing messages.
File
- ./
invite.install, line 218 - Installation file for invite module.
Code
function invite_update_8() {
$ret = array();
db_change_field($ret, 'invite', 'message', 'data', array(
'type' => 'text',
'not null' => TRUE,
'default' => '',
));
// Convert existing messages
$result = db_query("SELECT reg_code, data FROM {invite} WHERE data <> ''");
while ($row = db_fetch_object($result)) {
if (drupal_substr($row->message, 0, 2) == 'a:') {
// Already serialized
continue;
}
$data = array(
'subject' => NULL,
'message' => $row->data,
);
db_query("UPDATE {invite} SET data = '%s' WHERE reg_code = '%s'", serialize($data), $row->reg_code);
}
return $ret;
}