Welcome Guest, Not a member yet? Register   Sign In
Active Record and native MySQL functions.
#1

[eluser]lszanto[/eluser]
I have looked around and it doesn't seem to be possible but in active record I use the insert() function to insert my data. For a date field in MySQL I need to use the NOW() function built into MySQL. Is there any way to do this while still in Active Record?

Thanks in advance, Luke
#2

[eluser]lszanto[/eluser]
Don't worry I got it sorted. I had to simply make the php date() function match the same format as my datetime field. If anybody else has this issue, the format is
Code:
date("Y-m-d H:m:s")
#3

[eluser]nZac[/eluser]
Thanks for the post Iszanto, I had the same question!
#4

[eluser]John_Betong[/eluser]
[quote author="lszanto" date="1245491503"]I have looked around and it doesn't seem to be possible but in active record I use the insert() function to insert my data. For a date field in MySQL I need to use the NOW() function built into MySQL. Is there any way to do this while still in Active Record?

Thanks in advance, Luke[/quote]
 
Hi lszanto,

Initially I found Php and MySql handling of dates is overwhelming. I tried numerous ways to store NOW() and eventually left it up to MySql to do it all for me.
 
[code]

Check out:
1. field type: TIMESTAMP
2. field default: CURRENT_TIMESTAMP
3. field attributes: on update CURRENT_TIMESTAMP

[code]
 
 
 




Theme © iAndrew 2016 - Forum software by © MyBB