I had noticed this too, however I just added this to my model.
Cheers,
Adam
function beforeSave(){
if (isset($this->data[$this->alias]['parent_id']) &&
empty($this-
>data[$this->alias]['parent_id'])){
$this->data[$this->alias]['parent_id'] = null;
}
return true;
}
On Apr 5, 6:25 am, acoustic_overdrive <[EMAIL PROTECTED]>
wrote:
> I noticed that when I insert a new item into a tree using the
> TreeBehaviour, if I leave the parent_id blank, the resulting insert
> query sets parent_id to '' (an empty string). This causes MySQL to set
> the field to 0 even if NULL is the default. So all newly created items
> that don't have parents are given a parent of 0 rather than NULL.
> Obviously it would be better to have cake insert NULL, but I suppose
> this would mean modifying the TreeBehaviour which I'm not too keen on
> as it's part of the core.
>
> The strange thing is that when a previously inserted item is Edited
> and saved without changing the data, NULL is set in the query,
> correctly. Perhaps it's something in the database abstraction layer?
> It must handle null values as empty strings when inserting and as NULL
> when updating?
>
> This was mentioned a few years ago
> here:http://groups.google.com/group/cake-php/browse_thread/thread/a26e4032...
>
> Any assistance would be great. I'm using a recent cake 1.2 nightly,
> but it seems to happen with the beta too.
>
> Jamie
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---