function sms_user_update_1 in SMS Framework 5
Same name and namespace in other branches
- 6.2 modules/sms_user/sms_user.install \sms_user_update_1()
- 7 modules/sms_user/sms_user.install \sms_user_update_1()
Update: Storing user numbers in separate table
File
- modules/
sms_user/ sms_user.install, line 33
Code
function sms_user_update_1() {
$ret = array();
// Add table
$ret[] = update_sql("CREATE TABLE {sms_user} (\n uid int(10) NOT NULL,\n delta varchar(32),\n number varchar(32) NOT NULL,\n status tinyint(4) NOT NULL,\n code varchar(4) NOT NULL,\n gateway longtext,\n PRIMARY KEY (uid, delta),\n UNIQUE KEY number (number)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */ ");
$result = db_query("SELECT uid, data FROM {users} WHERE uid <> 0");
while ($user = db_fetch_array($result)) {
$data = unserialize($user['data']);
if ($data['sms_user']) {
$sms_data = $data['sms_user'];
db_query("INSERT INTO {sms_user} (number, status, code, gateway, uid, delta) VALUES ('%s', %d, '%s', '%s', %d, %d)", array(
$sms_data['number'],
$sms_data['status'],
$sms_data['code'],
serialize($sms_data['gateway']),
$user['uid'],
0,
));
unset($data['sms_user']);
$ret[] = update_sql("UPDATE {users} SET data = '" . serialize($data) . "' WHERE uid = " . $user['uid']);
}
}
return $ret;
}