I have three ten column tables, in all the tables in the I want to replace "March" with "January - March". As I have about 3000 rows, manually editting is not feasible. I therefore tried the following in PhpMyAdmin
UPDATE `drupal_tablemanager_data` SET `data` = replace(data, "March", "January - March")
or
UPDATE `drupal_tablemanager_data` SET `data` = replace(data, 'March', 'January - March')
or
UPDATE `drupal_tablemanager_data` SET `data` = replace(data, '"March"', '"January - March"')

All of which mess up the formatting of the table - any suggestions to help me?

Thanks

Comments

pobster’s picture

Status: Active » Closed (fixed)

Yes, use php serialize to insert data manually into the database, you only have to look at the module code to see an example.

  $row = serialize($row);
  // update database
  db_query("UPDATE {tablemanager_data} SET data='%s', format=%d WHERE id=%d", $row, $form['format'], $form['row']);

Problem you're having is likely due to the way serialize 'measures' the length of the string in an array, hence if you're changing the string you also need to change the numeric length. Eg. i:6:iphone -> 6 character length

Pobster