Re: SaveAll issue with nested arrays

2012-07-13 Thread Albert 'Tigr'
Oh, I don't know. Just give it a try. First create() and then 
saveAll(request->data). It may help.

On Thursday, July 12, 2012 4:27:20 PM UTC+2, Michael wrote:
>
> This is from the docs:
>
> "The saveAll function is just a wrapper around the saveMany and 
> saveAssociated methods. it will inspect the data and determine what type 
> of save it should perform. If data is formatted in a numerical indexed 
> array, saveMany will be called, otherwise saveAssociated is used."
>
> So using saveAll should handle what I wanted. It might just be a bug.
>
> As for calling the create() and set() before saving, Im not really sure 
> why its needed since the code seems to create the record for you if 
> there isn't an id passes with it.
>

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: SaveAll issue with nested arrays

2012-07-12 Thread Michael Gaiser
This is from the docs:

"The saveAll function is just a wrapper around the saveMany and
saveAssociated methods. it will inspect the data and determine what type of
save it should perform. If data is formatted in a numerical indexed array,
saveMany will be called, otherwise saveAssociated is used."

So using saveAll should handle what I wanted. It might just be a bug.

As for calling the create() and set() before saving, Im not really sure why
its needed since the code seems to create the record for you if
there isn't an id passes with it.

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: SaveAll issue with nested arrays

2012-07-11 Thread Albert 'Tigr'
I thought saveAll was for saving multiple rows into the same table while 
saveAssociated was for saving to multiple tables...
And do not forget to create() or set()  your data to model before saving.

On Tuesday, July 10, 2012 2:57:15 PM UTC+2, Michael wrote:
>
> When I pass this array to my saveAll function, the events get saved but the 
> feeding and the character do not. Is there an issue with multiple levels of 
> indexed arrays? Would I be better off trying to save them individually? 
>
>
>
> array(
>   (int) 0 => array(
>   'Event' => array(
>   'event_type_id' => (int) 1,
>   'chronicle_id' => '1',
>   'start_date' => '2011-08-21',
>   'end_date' => '2011-08-21',
>   'confirmed_id' => (int) 1,
>   'location_id' => '4',
>   'created' => '2011-08-21 04:19:24'
>   ),
>   'Feeding' => array(
>   (int) 0 => array(
>   'location_id' => '42',
>   'amount' => '11',
>   'created' => '2011-08-21 04:19:24'
>   ),
>   (int) 1 => array(
>   'location_id' => '38',
>   'amount' => '11',
>   'created' => '2011-08-21 04:17:09'
>   ),
>   (int) 2 => array(
>   'location_id' => '46',
>   'amount' => '11',
>   'created' => '2011-08-21 04:18:03'
>   )
>   ),
>   'Character' => array(
>   (int) 0 => array(
>   'character_id' => '35',
>   'role_id' => (int) 5
>   )
>   )
>   ),
>
> )
>
>
> Thanks.
>
>
>

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: SaveAll issue with nested arrays

2012-07-10 Thread Sergei
Whats your Cake version? Recently I had kinda similar problem with Cake 2.2.

I've encountered a weird behavior with nested array and saveAll 
function. Seems like it transforms your array to this before saving:

'Feeding' => array(

'Feeding' => array(

 (int) 0 => array(
'location_id' => '42',
'amount' => '11',
'created' => '2011-08-21 04:19:24'
)),

'Feeding' => array (

  (int) 1 => array(

'location_id' => '38',
'amount' => '11',
'created' => '2011-08-21 04:17:09'
)),

...


It adds another nested array for each data item. I think it's a bug.

-- 
Sergei


On Tuesday, July 10, 2012 9:57:15 PM UTC+9, Michael wrote:
>
> When I pass this array to my saveAll function, the events get saved but the 
> feeding and the character do not. Is there an issue with multiple levels of 
> indexed arrays? Would I be better off trying to save them individually? 
>
>
>
> array(
>   (int) 0 => array(
>   'Event' => array(
>   'event_type_id' => (int) 1,
>   'chronicle_id' => '1',
>   'start_date' => '2011-08-21',
>   'end_date' => '2011-08-21',
>   'confirmed_id' => (int) 1,
>   'location_id' => '4',
>   'created' => '2011-08-21 04:19:24'
>   ),
>   'Feeding' => array(
>   (int) 0 => array(
>   'location_id' => '42',
>   'amount' => '11',
>   'created' => '2011-08-21 04:19:24'
>   ),
>   (int) 1 => array(
>   'location_id' => '38',
>   'amount' => '11',
>   'created' => '2011-08-21 04:17:09'
>   ),
>   (int) 2 => array(
>   'location_id' => '46',
>   'amount' => '11',
>   'created' => '2011-08-21 04:18:03'
>   )
>   ),
>   'Character' => array(
>   (int) 0 => array(
>   'character_id' => '35',
>   'role_id' => (int) 5
>   )
>   )
>   ),
>
> )
>
>
> Thanks.
>
>
>

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: SaveAll issue with nested arrays

2012-07-10 Thread Michael Gaiser
Yes. Events hasMany Feedings(events_feedings) & Characters
(characters_events), and they belongTo the Event.


On Tue, Jul 10, 2012 at 3:30 PM, Harsha M V  wrote:

> what are the relations of the models ? does Events hasMany with feedings
> and characters ?
>
>
>
> --
> 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+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: SaveAll issue with nested arrays

2012-07-10 Thread Harsha M V
what are the relations of the models ? does Events hasMany with feedings 
and characters ?

 

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


SaveAll issue with nested arrays

2012-07-10 Thread Michael Gaiser
When I pass this array to my saveAll function, the events get saved
but the feeding and the character do not. Is there an issue with
multiple levels of indexed arrays? Would I be better off trying to
save them individually?



array(
(int) 0 => array(
'Event' => array(
'event_type_id' => (int) 1,
'chronicle_id' => '1',
'start_date' => '2011-08-21',
'end_date' => '2011-08-21',
'confirmed_id' => (int) 1,
'location_id' => '4',
'created' => '2011-08-21 04:19:24'
),
'Feeding' => array(
(int) 0 => array(
'location_id' => '42',
'amount' => '11',
'created' => '2011-08-21 04:19:24'
),
(int) 1 => array(
'location_id' => '38',
'amount' => '11',
'created' => '2011-08-21 04:17:09'
),
(int) 2 => array(
'location_id' => '46',
'amount' => '11',
'created' => '2011-08-21 04:18:03'
)
),
'Character' => array(
(int) 0 => array(
'character_id' => '35',
'role_id' => (int) 5
)
)
),

)


Thanks.

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php