Thursday, October 28, 2010

Re: How to insert an empty string with CakePHP

please post your sql debug output (the produced queries)


On 28 Okt., 12:52, Caroline <cdotc...@gmail.com> wrote:
> Thanks for your replies.
> Yes I might try to file it in trac, like you suggest, Cricket.
>
> Euromark, yes my field is varchar NOT NULL and I don't think I have a
> bug because it is a pretty straight forward operation. Only when the
> field is blank, it seems to be ignored. If you don't have the problem,
> could you please post your bit of code?
> That would be much appreciated.
>
> On Oct 28, 6:48 pm, euromark <dereurom...@googlemail.com> wrote:
>
>
>
>
>
>
>
> > must be a bug on your side
> > i can always empty my fields this way!
> > is your field set to varchar(x) NOT NULL?
>
> > On 28 Okt., 05:40, cricket <zijn.digi...@gmail.com> wrote:
>
> > > On Wed, Oct 27, 2010 at 8:00 PM, Caroline <cdotc...@gmail.com> wrote:
> > > > Hi,
> > > > I am trying to update a field to an empty string in my DB. Sounds
> > > > simple and I cannot find anybody else with the problem so I am
> > > > thinking I must be doing something really wrong...
>
> > > > If I have a record in the DB with some value in 'description', for
> > > > example, and I do
>
> > > > $data = array('id'=>1, 'name'=>'test', 'description'=>'');
> > > > $this->model->save($data);
>
> > > > then the description will remain unchanged. I don't want to put 'NULL'
> > > > or any other thing in the field, just an empty string.
>
> > > > Is it possible? What am I missing?
> > > > Thanks for any clue!
>
> > > This has come up before. Apparently, it's a feature, not a bug. I
> > > can't remember if anyone ever explained why. I doubt it. You could
> > > file a bug and see if anyone deigns to explain the 'wontfix' that'll
> > > be dropped on it inside of 24 hours.
>
> > > Personally, I prefer to set the field as NULL. If the column is
> > > defined as NOT NULL, then there's likely a good reason why some value
> > > must be present. I know--the empty is string != NULL, but anyway ...

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: