Datamapper Automated Timestamp Issue |
[eluser]naren_nag[/eluser]
If you give me a SQL statement of your DB structure, I will write out a MVC and give it to you in around six hours time.
[eluser]akachrislee[/eluser]
I found something interesting, i'm not sure if its this is supposed to happen but... When I also create a new guardian (inserting as opposed to updating), both the created and updated fields are being populated. is this suppose to happen? My understanding is that when you do an insert, it will fill in the created field. and when it does an update it will fill in the updated field.
[eluser]naren_nag[/eluser]
Code below. You'll still have to fill in the blanks. I think the reason you're getting the error is because your view most probably has created_on and updated_on as hidden/text input fields and these get posted and saved in your current controller. I've suggested a different, and definitely more secure approach, which will also help you avoid XSS attacks. Read the code and comments, try it out and let me know if you have a problem. cheers, Naren The model: Code: <?php The controller : Code: <?php The view Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
[eluser]dmeza[/eluser]
We're getting the same error in mac and pc xp, mysql 5.0.77 and php 5.1.6. The error does not show up in our dev server in linux or other pc vista envs. We're using the standard 'created' and 'updated' names in the mysql tables with no configuration for their names anywhere in the models or config files.
[eluser]akachrislee[/eluser]
what type is the column updated in your database? it should be datetime. also not sure if you need the +0000 at the end. of the timestamp.
[eluser]dmeza[/eluser]
[quote author="akachrislee" date="1267494740"]what type is the column updated in your database? it should be datetime. also not sure if you need the +0000 at the end. of the timestamp. [/quote] "created" and "updated" are datetime mysql datatypes. For what I've read in some other places the +xxxx is the timezone. The solution is in this post and it seems to be a known issue. http://ellislab.com/forums/viewthread/112904/P679/ Quote: ............... That’s the timezone. It’s is part of the standard, ISO accepted formats for timestamps. Either you live in the GMT/UTC time zone, or your server is incorrectly configured, which is why you see a TZ of +0000. Mine, for example, is -0500. If your database cannot accept timezone values, you’ll have to manually change DMZ (this is going to be a configuration option in the future). Open libraries/datamapper.php, scroll to the save function, and change the two occurrences of ‘Y-m-d H:i O’ to ‘Y-m-d H:i’. .................
[eluser]ciGR[/eluser]
By method name, I understand that you want to update an already existing entry, I think you must use Code: $g = new Guardian($id); Code: $g = new Guardian(); EDIT I did not see the last answers.
[eluser]baba[/eluser]
i had the same issue. just changed Code: $config['timestamp_format'] = 'Y-m-d H:i:s'; in application/config/datamapper.php and it works fine now. hope this helps |
Welcome Guest, Not a member yet? Register Sign In |