For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > January 2006 > TIMESTAMP issues...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author TIMESTAMP issues...
presley2@comcast.net

2005-12-08, 6:59 pm

Hi,
I want to create an auto creation date and update date in my mysql
table. I am using the "MySQL Cookbook" approach, using the TIMESTAMP
field which basically is:
- create 2 new fields in the table (t_create and t_update)
- both NULL
- when a new record is created they both will register a common
timestamp
- when the record is modified the t_update will change, buit not the
t_create

sounds EZ---funny I got it to work on another table --but not this one!

My problem is:
1) I can create 1 NULL TIMESTAMP field --using PhPMyAdmin 2.6. ---the
2nd NULL TIMESTAMP field auto enters '0000000000000000' not NULL in the
field on creation---I try to change the field to NULL ...but it
automatically reverts NULL to '0000000'...why?
2) My results are: one correct TIMESTAMP field ---changes with each
modiifcation and one TIMESTAMP field which stays at '000000000' all the
time
3) Funny---When "browsing" the record in PhPMyAdmin you are allowed to
change the parameters of the TIMESTAMP field ---in that record
only---and then I can get a TIMESTAMP (create and update) in both
fields --- but only manually and after a new record is entered

I think this is a very EZ problem ---that is related to my
misunderstanding about formatting TIMESTAMP fields and using PhpMyAdmin
......I hope to hear from you !

Thanks,
Newbie Jim

Jim Michaels

2006-01-19, 3:57 am

possibly because 0 is often the equivelant of NULL in a number of languages,
but not in SQL. This is a funny thing about they way PHPAdmin was
implemented. I really don't know why they chose to do it that way. There
must be some way to detect if a field is NULL or not coming out of a
database. If there isn't, there's your answer.
once PHPMyAdmin upgrades to the mysqli functions maybe things will change.

<presley2@comcast.net> wrote in message
news:1134077379.880365.37580@z14g2000cwz.googlegroups.com...
> Hi,
> I want to create an auto creation date and update date in my mysql
> table. I am using the "MySQL Cookbook" approach, using the TIMESTAMP
> field which basically is:
> - create 2 new fields in the table (t_create and t_update)
> - both NULL
> - when a new record is created they both will register a common
> timestamp
> - when the record is modified the t_update will change, buit not the
> t_create
>
> sounds EZ---funny I got it to work on another table --but not this one!
>
> My problem is:
> 1) I can create 1 NULL TIMESTAMP field --using PhPMyAdmin 2.6. ---the
> 2nd NULL TIMESTAMP field auto enters '0000000000000000' not NULL in the
> field on creation---I try to change the field to NULL ...but it
> automatically reverts NULL to '0000000'...why?
> 2) My results are: one correct TIMESTAMP field ---changes with each
> modiifcation and one TIMESTAMP field which stays at '000000000' all the
> time
> 3) Funny---When "browsing" the record in PhPMyAdmin you are allowed to
> change the parameters of the TIMESTAMP field ---in that record
> only---and then I can get a TIMESTAMP (create and update) in both
> fields --- but only manually and after a new record is entered
>
> I think this is a very EZ problem ---that is related to my
> misunderstanding about formatting TIMESTAMP fields and using PhpMyAdmin
> .....I hope to hear from you !
>
> Thanks,
> Newbie Jim
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com