2

In project with plain php and mysql I have table app_users and need add column with type array and default value empty array, I try:

ALTER TABLE app_users ADD setting_notification tinytext COLLATE utf8_unicode_ci NOT NULL COMMENT '(DC2Type:array)' DEFAULT 'a:0:{}'

have error:

[SQL]ALTER TABLE app_users ADD setting_notification tinytext COLLATE utf8_unicode_ci NOT NULL COMMENT '(DC2Type:array)' DEFAULT 'a:0:{}'

[Err] 1101 - BLOB/TEXT column 'setting_notification' can't have a default value

How to correct add default value to tinytest column (like array for php) ?

shuba.ivan
  • 3,824
  • 8
  • 49
  • 121
  • 1
    Lucky for you that you ran into an error http://stackoverflow.com/questions/3653462/is-storing-a-delimited-list-in-a-database-column-really-that-bad/3653574 – e4c5 Dec 16 '16 at 08:32
  • gothrough the link http://stackoverflow.com/questions/3466872/why-cant-a-text-column-have-a-default-value-in-mysql. – Karthikeyan Vivekanandhan Dec 16 '16 at 08:38
  • This is MYSQL Config problem – Karthikeyan Vivekanandhan Dec 16 '16 at 08:38
  • @KarthikeyanVivekanandhan it isn't, please don't spread misinformation. A great solution to this apparent problem would be if you could use MySQL 5.7 and utilize its `JSON` column. Instead of saving a serialized array like you're trying to now, you could simply store a `JSON` representation of that array. There are multiple benefits to `JSON` columns, so if you have the option to use the correct tool - you should. – Mjh Dec 16 '16 at 10:07
  • @Mjh I am not spreading wrong information. I am also told the Version Problem. – Karthikeyan Vivekanandhan Dec 16 '16 at 11:15
  • @KarthikeyanVivekanandhan you **are** spreading false information. If it's configuration problem, why haven't you posted how to fix it? Is it because you don't know how? Also I have no clue what "I am also told the Version Problem" means. – Mjh Dec 16 '16 at 11:17

0 Answers0