Silverstripe Version: 4.2.1
PHP 7.0.8
Question:
I have a dataobject page that has a varchar(100) field called DropOffLocations for saving of CheckboxSetField selections.
The selections were getting saved in the database as comma delimited i.e. 1,2,3
Now suddenly the values are saving as [“1”,“2”,“3”].
But the weird thing is, on the development test server, same code, the values are getting stored as 1,2,3
This breaks a query using the following where statement:
$filter = "ID IN(".$getlocation->DropOffLocations.")";
$page = VehicleLocations::get()->where($filter);
Debug output:
FROM “VehicleLocations” WHERE (ID IN([“1”,“3”,“8”])) 42000-1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘[“1”,“3”,“8”]))’ at line 5
UPDATE:
Appears this is a issue from upgrading from silverstripe 3.x to silverstripe 4.x. Not a bug. In 4.x, data is saved as a JSON object. So a gotcha. Was only a issue when I updated checkbox selections…
See:
My solution was to add relation object to save into.