Welcome Guest, Not a member yet? Register   Sign In
Datamapper timestamp fields
#1

[eluser]The Mask[/eluser]
Hi,

In my datamapper configuration file I have the following:
$config['created_field'] = 'created';
$config['updated_field'] = 'updated';

But when I try to save a relationship, I get:
Field 'created' doesn't have a default value
INSERT INTO `users_members` (`user_id`, `application_id`) VALUES (26, 7)

Any ideas? The documentation says that the created/updated columns are taken care of and no need to set them.

Thanks
#2

[eluser]The Mask[/eluser]
Just had a thought. Because the table is only used to save a relationship, I'm betting timestamp fields are not required/maintained for these.

In my example though, the date created would represent the date when a user sas given access to an application and so would be useful information to capture.

Would be good to have this confirmed though.
#3

[eluser]BrianDHall[/eluser]
I believe the problem is in your DB - you need to set the timestamp fields to NULL, I believe. Datamapper first saves data, then later saves relationships, so it is possible that timestamp works this way too. I've always set them to NULL (therefore no default value needed) just in case and its worked Smile
#4

[eluser]The Mask[/eluser]
I put the columns back in and set them to NULL but after a relationship record is written, the values remain NULL so going to take them out again as I can live without them - but thanks for the response.

I assume these are not maintained for relationship tables. Maybe Oz could confirm this?




Theme © iAndrew 2016 - Forum software by © MyBB