[PHP] Updating Timestamps
I'm using timestamps (God bless the little things) to keep track of database updates, so to give users the latest updates by the second. Kinda neat. But anyway, the timestamps are in one table, and when something is that table is changed, it automatically updates. However, I have another table which I want to affect the timestamps. Is there a command for 'manually' updating a timestamp rather than by SQL's own logic? Thanks in advance. Cosmin Laslau _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Updating Timestamps
This is more of a MySQL question than a PHP question, but... The TIMESTAMP format in MySQL isn't a read-only field -- you can update the data with your own timestamp information just like you can any other normal database field. So, simply create a timestamp using PHP and insert that into the field in MySQL. --kurt On Monday 26 November 2001 07:27 pm, cosmin laslau wrote: I'm using timestamps (God bless the little things) to keep track of database updates, so to give users the latest updates by the second. Kinda neat. But anyway, the timestamps are in one table, and when something is that table is changed, it automatically updates. However, I have another table which I want to affect the timestamps. Is there a command for 'manually' updating a timestamp rather than by SQL's own logic? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Updating Timestamps
On Tue, 27 Nov 2001 13:57, cosmin laslau wrote: I'm using timestamps (God bless the little things) to keep track of database updates, so to give users the latest updates by the second. Kinda neat. But anyway, the timestamps are in one table, and when something is that table is changed, it automatically updates. However, I have another table which I want to affect the timestamps. Is there a command for 'manually' updating a timestamp rather than by SQL's own logic? Thanks in advance. Cosmin Laslau The Mysql docs say: Automatic updating of the rst TIMESTAMP column occurs under any of the following conditions: The column is not specified explicitly in an INSERT or LOAD DATA INFILE statement. The column is not specified explicitly in an UPDATE statement and some other column changes value. (Note that an UPDATE that sets a column to the value it already has will not cause the TIMESTAMP column to be updated, because if you set a column to its current value, MySQL ignores the update for efficiency.) You explicitly set the TIMESTAMP column to NULL. TIMESTAMP columns other than the first may also be set to the current date and time. Just set the column to NULL or to NOW(). You can set any TIMESTAMP column to a value different than the current date and time by setting it explicitly to the desired value. This is true even for the rst TIMESTAMP column. You can use this property if, for example, you want a TIMESTAMP to be set to the current date and time when you create a row, but not to be changed whenever the row is updated later: Let MySQL set the column when the row is created. This will initialize it to the current date and time. When you perform subsequent updates to other columns in the row, set the TIMESTAMP column explicitly to its current value. On the other hand, you may find it just as easy to use a DATETIME column that you initialize to NOW() when the row is created and leave alone for subsequent updates. TIMESTAMP values may range from the beginning of 1970 to sometime in the year 2037, with a resolution of one second. Values are displayed as numbers. -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA WWhhaatt ddooeess dduupplleexx mmeeaann?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Updating Timestamps
The easiest way is to use an SQL query like this; update your_table set timestamp_field=null; This sets the timestamp to the current time automagically. You can of course add a where clause and so on to this query. Ben On Monday, November 26, 2001, at 09:27 PM, cosmin laslau wrote: I'm using timestamps (God bless the little things) to keep track of database updates, so to give users the latest updates by the second. Kinda neat. But anyway, the timestamps are in one table, and when something is that table is changed, it automatically updates. However, I have another table which I want to affect the timestamps. Is there a command for 'manually' updating a timestamp rather than by SQL's own logic? Thanks in advance. Cosmin Laslau _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]