Re: pear mdb2 and null

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Phpster wrote:


On Apr 11, 2009, at 21:38, "Michael A. Peters" <mpeters@xxxxxxx> wrote:

I've run into a small issue with mdb2.

I have a mysql database with a field set to longtext not null.

inserting "" into that field works just dandy when using the mysql_ functions.

However, when using mdb2 - it converts "" to NULL which is NOT what I want to have happen, and the result is that the execute() fails because the database table does not accept NULL for that field.

Why does mdb2 turn "" into NULL for a text type when MySQL knows there is a difference? How do I suppress that?

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


Why not set a default in the field then, as am empty string and let the db handle field properly? Having a Not Null with no default is bad db design.

I need it to error when an attempt to create a record without setting that field is attempted, but setting the field to an empty string is fine.

Attempting to insert data without defining that field indicates there is not sufficient information to create a record. Setting that field to a zero length string however indicates that there is enough information to create a record. Assuming that no information is the same as an zero length string is not OK.

Call it bad design if you want, by MySQL knows the difference between NULL and an empty string, so should my database abstraction layer.

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux