" and 0 aren't NULL in MySQL 4.1.1
ezContents is a Web site content management system in the form of a Dr
Brought to you by:
mlyczba
I was setting up menus in ezContents 2.0.3. I could
successfully add 1 menu item, but if I tried to add a
second one it gave an error, saying that the key '0'
was already in use.
I asked my husband about it (he knows a bit about
MySQL) and he fixed the problem.
Apparently MySQL 4.1.1 comes with the flag
sql-mode=NO_AUTO_VALUE_ON_ZERO
which meant that the database was inserting the
entries with a key of 0 instead of auto-incrementing.
I guess the auto-increment only works with NULL (not 0
or " ) if that flag is set.
Niki Thornock
niki_thornock@yahoo.com
Logged In: NO
I suppose it's only fair to note that
sql-mode=NO_AUTO_VALUE_ON_ZERO is not set by default in
MySQL. It is, however, an available setting that MySQL
added as of version 4.1.1 in response to a bug report, and
it is a setting that may come into fairly common usage.
In any event, the "correct" value to insert into an
auto-increment field has always been NULL. Support for zero
and '' are only provided as a convenience.