CodeIgniter Forums
Active Record and native MySQL functions. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Active Record and native MySQL functions. (/showthread.php?tid=19831)



Active Record and native MySQL functions. - El Forum - 06-19-2009

[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


Active Record and native MySQL functions. - El Forum - 06-19-2009

[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")



Active Record and native MySQL functions. - El Forum - 06-20-2009

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


Active Record and native MySQL functions. - El Forum - 06-20-2009

[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]