Home » Database » DB_DataObject » Bug #6708
Null columns not working with int type in mysql
Details
| Submitted | 2006-02-06 18:13 UTC |
|---|---|
| From | op7 at accedo dot es |
| Status | Bogus |
| Package | DB_DataObject |
| PHP Version | 4.4.2 |
| Roadmaps | (Not assigned) |
Comments
[2006-02-06 18:13 UTC] op7 at accedo dot es
Description:
------------
Hi, I don't know if I'm forgetting something, but I found a strange behavior with null/not null working with int type(MySQL).
The fact is that I want to use a field of type int alternatively, but don't store 0s in the empty fields, just nulls. I've changed field descriptions in the DB (allow null, and removed 0 from default) and succesfully tested to input null registries in the table with direct mysql queries, but using a DB_DataObject I always recieved a 0 value.
With this following patch works right, may someone could tellme if this is a bug or really I'm forgetting something...
Test script:
---------------
(In DataObject.php)
1007c1007,1010
< $rightq .= ' ' . intval($this->$k) . ' ';
---
> if(strlen($this->$k) || ($v & DB_DATAOBJECT_NOTNULL))
> $rightq .= ' ' . intval($this->$k) . ' ';
> else
> $rightq .= 'null';
[2006-02-07 07:40 UTC] op7 at accedo dot es
Sorry I only provided code for the insert function...