function matrix_update_620 in Matrix field 6.2
function matrix_update_613() { $result = db_query("SELECT field_name, global_settings FROM {node_field} WHERE type = 'matrix'"); while ($row = db_fetch_object($result)) { $old = unserialize($row->global_settings); foreach ($old as $item => $value) { $a = explode('_', $item); if ($a[0] == 'label' && $a[1] == 'row' && !empty($value)) { $rows[] = $value; } if ($a[0] == 'label' && $a[1] == 'column' && !empty($value)) { $column[] = $value; } } $new = array('rows' => implode("\n", $rows), 'cols' => implode("\n", $column), 'size' => '15'); db_query("UPDATE {node_field} SET global_settings = '%s' WHERE field_name = '%s'", serialize($new), $row->field_name); } }
File
- ./
matrix.install, line 112 - Installer for the matrix module
Code
function matrix_update_620() {
$result = db_query("SELECT field_name, global_settings FROM {content_node_field} WHERE type = 'matrix'");
while ($row = db_fetch_object($result)) {
$old = unserialize($row->global_settings);
$old_rows = explode("\n", $old['rows']);
$old_cols = explode("\n", $old['cols']);
$old_size = $old['size'];
foreach ($old_cols as $value) {
$new_cols[] = array(
'#type' => 'textfield',
'#title' => trim($value),
'#required' => FALSE,
);
}
foreach ($old_rows as $value) {
$new_rows[] = array(
'#type' => 'title',
'#title' => trim($value),
);
}
$new = array(
'mode' => 'cols',
'rows_elements' => serialize($new_rows),
'cols_elements' => serialize($new_cols),
);
db_query("UPDATE {content_node_field} SET global_settings = '%s' WHERE field_name = '%s'", serialize($new), $row->field_name);
}
$res[] = array(
'success' => TRUE,
'query' => 'Matrix fields updated',
);
return $res;
}