its nothing to do with php as your working from the shell in your eg.

mysql will default to 2000 for a year value if you pass it "" as an entry because it 
will accept short values for the years this century, eg pass it "1" and it'll give you 
2001, so it thinks "" is nothing. if you want to default to this year pass it NOW().


-----Original Message-----
From: Peter Beckman [mailto:[EMAIL PROTECTED]
Sent: 27 August 2003 02:40
To: [EMAIL PROTECTED]
Subject: [PHP-DB] MySQL, PHP or ghost?


Seems that either I don't understand mysql, or something.

My table, with the non-important things removed...

    mysql> explain plate;
    
+---------+-----------------------+------+-----+---------------------+----------------+
    | Field   | Type                  | Null | Key | Default             | Extra       
   |
    
+---------+-----------------------+------+-----+---------------------+----------------+
    | pid     | mediumint(8) unsigned |      | PRI | NULL                | 
auto_increment |
    | year    | year(4)               | YES  |     | NULL                |             
   |
    [...]

So my assumption is that if I insert with year="" it should use the
default.  Or at least 0000.

    mysql> update plate set year=NULL where pid=65;
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 0

    mysql> select * from plate where pid=65;
    +-----+---------+------+-
    | pid | plate   | year |
    +-----+---------+------+-
    |  65 | DVF0343 | NULL |
    +-----+---------+------+-

But if I do this:

    mysql> update plate set year="" where pid=65;
    Query OK, 1 row affected (0.01 sec)
    Rows matched: 1  Changed: 1  Warnings: 1

    mysql> select * from plate where pid=65;
    +-----+---------+------+-
    | pid | plate   | year |
    +-----+---------+------+-
    |  65 | DVF0343 | 2000 |
    +-----+---------+------+-

2000?  What?  Why?  Confused.  PHP or Mysql fault?

Beckman
---------------------------------------------------------------------------
Peter Beckman                                                  Internet Guy
[EMAIL PROTECTED]                             http://www.purplecow.com/
---------------------------------------------------------------------------

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to