• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DB_Forge, default value

#11
This is version-dependent. From the MySQL documentation:

Quote:Before MySQL 5.6.5, support for automatic initialization and updating is more limited:

  • DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP cannot be used with DATETIME columns.
  • DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP can be used with at most one TIMESTAMP column per table. It is not possible to have the current timestamp be the default value for one column and the auto-update value for another column.
Reply

#12
I was referring to the comment that "a table cannot have two timestamp fields", which is not true on its own. He didn't mention you can't have two timestamp columns that ALSO use the ON UPDATE CURRENT_TIMESTAMP clause, which would be true depending on the mysql version.
Reply

#13
SQL 92 has CURRENT_TIMESTAMP, doesn't it?

https://www.ibphoenix.com/resources/docu...gn/doc_169

(01-02-2015, 02:16 PM)mwhitney Wrote: Since almost anything which would require this functionality would be database-specific (and CURRENT_TIMESTAMP is certainly MySQL-specific), you're probably better off just defining the field as


PHP Code:
'Ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP'
Do you want to write tests for your apps? Our book, CodeIgniter Testing Guide would help you.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.