function notifications_update_6003 in Notifications 6.4
Same name and namespace in other branches
- 6 notifications.install \notifications_update_6003()
- 6.2 notifications.install \notifications_update_6003()
- 6.3 notifications.install \notifications_update_6003()
Add integer value to fields table
File
- ./
notifications.install, line 386
Code
function notifications_update_6003() {
$ret = array();
db_add_field($ret, 'notifications_fields', 'intval', array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'disp-width' => '11',
));
// Populate intval, this should depend on db type. Is there any way that works for all?
// For both, CAST produces an error when it is no integer that's why the regexp...
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql('UPDATE {notifications_fields} SET intval = CAST(value AS UNSIGNED) WHERE value REGEXP \'^-?[0-9]+$\'');
break;
case 'pgsql':
$ret[] = update_sql('UPDATE {notifications_fields} SET intval = CAST(value AS INTEGER) WHERE value SIMILAR TO \'^-?[0-9]+$\'');
break;
}
return $ret;
}