Mister,

I'll be damn. Works perfectly, and - what is more than expected - I
understand why!

Thanks a bunch.
Damn. Awesome :D


> Some of what you want to do is possible with the set class; other bits
> would be more complicated.
>
> With this approach, the best you could achieve would be a nasty mess
> of array_combine, array_keys and various set calls, all nested and
> difficult to follow.
>
> Although I love the Set class with all my heart, this is one instance
> where I believe a simple loop would be easier to code, easier to
> maintain, and ultimately more efficient for the server and the coder.
>
> foreach($data as $i => $bacon) {
>   $statusHistory = array();
>   foreach($bacon['StatusHistory'] as $eggs) {
>     $statusHistory[$eggs['StatusName']['text']] = array(
>       'since' => $eggs['since'],
>       'Changer' => $ggs['Changer']['full_name']
>     );
>   }
>   $data[$i]['StatusHistory'] = $statusHistory;
> }
>
> Job done!
>
> hth
> grigri
>
> On Apr 24, 9:16 am, "Faza" <f...@ansi.pl> wrote:
>> Hello again,
>>
>> this is the array I'm working on:
>>
>> Array
>> (
>>     [0] => Array
>>         (
>>             [Design] => Array
>>                 (
>>                     [id] => 39
>>                     [design_no] => 1
>>                     [job_title] => gjgfjyjgyjf
>>                     [expected_date] => 2009-04-14
>>                     [customer_id] => 5
>>                     [designer_id] => 15
>>                     [status_id] => 1
>>                     [post_date] => 2009-04-23 13:11:23.247263+02
>>                     [author_id] => 73
>>                 )
>>
>>             [Author] => Array
>>                 (
>>                     [full_name] => SKP Admin
>>                     [id] => 73
>>                 )
>>
>>             [Designer] => Array
>>                 (
>>                     [full_name] => Jan Grzenda
>>                     [id] => 15
>>                 )
>>
>>             [CustomerNr] => Array
>>                 (
>>                     [id] => 5
>>                     [customers_number_name] => Test (2343)
>>                 )
>>
>>             [StatusHistory] => Array
>>                 (
>>                     [0] => Array
>>                         (
>>                             [since] => 2009-04-21 00:00:00+02
>>                             [status_names_id] => 1
>>                             [changer_id] => 74
>>                             [design_id] => 39
>>                             [StatusName] => Array
>>                                 (
>>                                     [text] => Nowe
>>                                 )
>>
>>                             [Changer] => Array
>>                                 (
>>                                     [full_name] => John Doe
>>                                 )
>>
>>                         )
>>
>>                     [1] => Array
>>                         (
>>                             [since] => 2009-04-23 14:17:11.673985+02
>>                             [status_names_id] => 2
>>                             [changer_id] => 74
>>                             [design_id] => 39
>>                             [StatusName] => Array
>>                                 (
>>                                     [text] => Przydzielone grafikowi
>>                                 )
>>
>>                             [Changer] => Array
>>                                 (
>>                                     [full_name] => Ed Smith
>>                                 )
>>
>>                         )
>>
>>                 )
>>
>>         )
>>
>> I want to modify the [StatusHistory] branch.
>> So far, I'm extracting it using:
>>
>> $hist = Set::extract($designs, '{n}.StatusHistory');
>>
>> This results in:
>>
>> Array
>> (
>>     [0] => Array
>>         (
>>             [0] => Array
>>                 (
>>                     [since] => 2009-04-21 00:00:00+02
>>                     [status_names_id] => 1
>>                     [changer_id] => 74
>>                     [design_id] => 39
>>                     [StatusName] => Array
>>                         (
>>                             [text] => Nowe
>>                         )
>>
>>                     [Changer] => Array
>>                         (
>>                             [full_name] => John Doe
>>                         )
>>
>>                 )
>>
>>             [1] => Array
>>                 (
>>                     [since] => 2009-04-23 14:17:11.673985+02
>>                     [status_names_id] => 2
>>                     [changer_id] => 74
>>                     [design_id] => 39
>>                     [StatusName] => Array
>>                         (
>>                             [text] => Przydzielone grafikowi
>>                         )
>>
>>                     [Changer] => Array
>>                         (
>>                             [full_name] => Ed Smith
>>                         )
>>
>>                 )
>>
>>         )
>>
>> I've tried endless combine params, but without success.
>> I want to achieve this:
>>
>> Array
>> (
>>     [0] => Array
>>         (
>>             [Nowe] = (StatusName.text) => Array
>>                 (
>>                     [since] => 2009-04-21 00:00:00+02
>>                     [Changer] => John Doe = (Changer.full_name)
>>                 )
>>
>>             [Przydzielone grafikowi] => Array
>>                 (
>>                     [since] => 2009-04-23 14:17:11.673985+02
>>                     [Changer] => Ed Smith
>>                 )
>>
>>         )
>>
>> Last question, I want to replace the original [StatusHistory] with the
>> new
>> array.
>>
>> --
>> Jacek
> >
>


-- 
Jacek


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

Reply via email to