> On May 2, 11:44 am, QXY <q...@qxy.hu> wrote:
>
> > Hello!
>
> >http://bin.cakephp.org/saved/66911
>
> > First of all, I have to tell you I'm learning CakePHP, so if you see
> > something weird
> > please do not laugh or give negative criticism, because everybody was
> > beginner once. ;)
>
> I'm not laughing I'm wondering why your code looks so different from
> how the book, and everyone else, writes their code.
>
> > where in the book does it suggest doing create(find()); ?
>
> > Nowhere, but I don't understand, what is the problem? create(find()) or
> > simply using create?
>
> nesting calls like that, if nothing else , will make your code harder
> to debug/read.
>
> > why are you now passing false to create ..?
>
> > "Optional data array to assign to the model after it is created. If null
> > or false, schema data defaults are not merged."
> > I don't want defaults to be loaded to model. What's wrong with this?> It's probably in your interest to check the api.
>
> My Mistake.
PS I'd structure what you're doing like this:
$this->Model->create();
$this->Model->id = $this->Model->field('id', array('character' =>
$new_data['name']));
if ($this->Model->id) {
...
} else {
...
}
...
$this->Model->save($stuff);
and restrict $stuff to values that have changed. I assume character is
a unique field.
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
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
No comments:
Post a Comment