Home > Net >  Save json inside a Symfony migration
Save json inside a Symfony migration

Time:04-01

I have an Item entity which have an "access" field, typed as json, that is added through a migration. I'm trying to add also values in the table I'm editing, and fill this field, but I can't find the correct syntax. Currently I'm trying to do something like

$this->addSql(<<<SQL
    INSERT INTO `item` (`id`, `name`, `description`, `progress`, `price`, `category`, `access`) VALUES
    ('3',    'Hyperboost',  'Fait avancer de 5 cases', '5',   '2.5',   'personnal', [{"start": 65, "end": 100, "ranking": 'team'}]);
SQL);

CodePudding user response:

I think you just need single quotes

$this->addSql(<<<SQL
  INSERT INTO `item` (`id`, `name`, `description`, `progress`, `price`, `category`, `access`) VALUES
  ('3',    'Hyperboost',  'Fait avancer de 5 cases', '5',   '2.5',   'personnal', '[{"start": 65, "end": 100, "ranking": 'team'}]');

SQL);

  • Related