Welcome Guest, Not a member yet? Register   Sign In
Database Timestamp ?
#1

Hi guys

Quick question regarding database automatic timestamps.

From the User Guide ...


Quote:$useTimestamps

This boolean value determines whether the current date is automatically added to all inserts and updates. If true, will set the current time in the format specified by $dateFormat. This requires that the table have columns named ‘created_at’ and ‘updated_at’ in the appropriate data type.




Quote:$dateFormat

This value works with $useTimestamps to ensure that the correct type of date value gets inserted into the database. By default, this creates DATETIME values, but valid options are: datetime, date, or int (a PHP timestamp).


Which do you use and why?

Does the datetime option use the MySql timestamp, or is this not used at all.

Thanks
Reply
#2

@MeltedRolo,

When it comes to timestamps you can either use it from the web server where PHP is installed or the database server (assuming that they are not installed on the same server). In most of my cases I've used a combination of both. It just depends on the system and sometimes the location of the web server and or database server.
Reply
#3

Hi

Thanks for the reply.

I would really rather use the time from PHP, and was wondering which of the options above would be ruled out based on that decision, as I have no idea how the database model inserts or doesnt insert the timestamp fields.

Thanks
Reply
#4

Hi again.

Is my thinking correct on this.

The default is datetime, so my database columns will need to be VARCHAR(25).

If I choose INT, then my database columns will need to be INT(14).

If i,m using Mysql timestamps, then that's handled by the database, so I should not be using $useTimestamps = true.

Thanks
Reply
#5

No you use either TIMESTAMP or DATETIME for storing the date / time fields.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB