saveAll - fieldList question

3 messages Options
Embed this post
Permalink
Raph-2

saveAll - fieldList question

Reply Threaded More More options
Print post
Permalink

Hello,

Let's say I have a model Model1 with fields 'name' and 'date' and I
have a Model2 with field 'name'. Model1 is in relation 'hasMany' with
Model2. How should I use saveAll() method with "fieldList" parameter
if I only want to save all 'date' from Model1 and 'name' from Model2?
It looks like in "fieldList" array only fields' names without models'
names allowed i.e.

This will work:
$this->saveAll($data, array('fieldList' => array('date')));

but this won't:
$this->saveAll($data, array('fieldList' => array('date',
'Model2.0.name')));

this won't either:
$this->saveAll($data, array('fieldList' => array('date',
'Model2.name')));

Any suggestions?

--
Raph

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

mattalexx

Re: saveAll - fieldList question

Reply Threaded More More options
Print post
Permalink
Any luck figuring this one out?

On Nov 5, 3:15 am, Raph <[hidden email]> wrote:

> Hello,
>
> Let's say I have a model Model1 with fields 'name' and 'date' and I
> have a Model2 with field 'name'. Model1 is in relation 'hasMany' with
> Model2. How should I use saveAll() method with "fieldList" parameter
> if I only want to save all 'date' from Model1 and 'name' from Model2?
> It looks like in "fieldList" array only fields' names without models'
> names allowed i.e.
>
> This will work:
> $this->saveAll($data, array('fieldList' => array('date')));
>
> but this won't:
> $this->saveAll($data, array('fieldList' => array('date',
> 'Model2.0.name')));
>
> this won't either:
> $this->saveAll($data, array('fieldList' => array('date',
> 'Model2.name')));
>
> Any suggestions?
>
> --
> Raph

--

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


Dave-35

Re: saveAll - fieldList question

Reply Threaded More More options
Print post
Permalink
I would probably split it into two calls

assuming this code is in your Model1 model:

$this->saveAll($data['Model1'], array('fieldList' => array('date')));
$this->Model2->saveAll($data['Model2'], array('fieldList' => array('date')));

On Fri, Nov 13, 2009 at 8:52 AM, mattalexx <[hidden email]> wrote:
Any luck figuring this one out?

On Nov 5, 3:15 am, Raph <[hidden email]> wrote:
> Hello,
>
> Let's say I have a model Model1 with fields 'name' and 'date' and I
> have a Model2 with field 'name'. Model1 is in relation 'hasMany' with
> Model2. How should I use saveAll() method with "fieldList" parameter
> if I only want to save all 'date' from Model1 and 'name' from Model2?
> It looks like in "fieldList" array only fields' names without models'
> names allowed i.e.
>
> This will work:
> $this->saveAll($data, array('fieldList' => array('date')));
>
> but this won't:
> $this->saveAll($data, array('fieldList' => array('date',
> 'Model2.0.name')));
>
> this won't either:
> $this->saveAll($data, array('fieldList' => array('date',
> 'Model2.name')));
>
> Any suggestions?
>
> --
> Raph

--

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



--

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