MySQL checks
the contents to ensure valid date and time information, and offers special functions
to work on these fields.
Calendar Popup
As an added benefit, phpMyAdmin offers a calendar popup for easy data entry.
We will start by adding a DATE field, date_published, to our book table. If we go
into Insert mode, we should now see the new field where we could type a date. A
Calendar icon is also available:
Changing Table Structures
[ 106 ]
This icon brings a popup window, synchronized to this DATE field: if there is
already a value in the field, the popup displays accordingly. In our case, there is no
value in the field, so the calendar shows the current date:
Small symbols on each side of the month and year headers permit easy scrolling
through months and years, and a simple click on the date we want transports it to
our date_published field.
For a DATETIME or TIMESTAMP field, the popup offers to edit the time part:
Chapter 6
[ 107 ]
TIMESTAMP Options
Starting with MySQL 4.1.2, there are more options that can affect a TIMESTAMP
column. Let's add to our book table a column named stamp of type TIMESTAMP.
As soon as we choose TIMESTAMP from the Type drop-down list??”provided that
JavaScript has been activated in our browser??”we see a new checkbox under the
Default column: CURRENT_TIMESTAMP. Note that in the Attributes column, we
can choose ON UPDATE CURRENT_TIMESTAMP.
Pages:
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119