Re: Set::extract on an array containing one element

2011-05-06 Thread Gluckens
Thanks for your replies.

I understand the differences between the 2 types of array.
I only asked why when I add another key and end up with array(4=>$a,
12=>$b), NOW the Set::extract is working as normal.

As for the combination of extract and combine, I believe there could
be situations where it's useful.
In my case, I take the result of my find and combine the array in a
way that I can group data of the same type together.
This allow me to do a simple foreach on every type possible (they can
vary) and compute stats for each of them based on their data.
There are surely other ways to do it, but depending on different
factors, this is the quickest and cleanest I've found.

So this result of find
Array
(
[0] => Array
(
[data] => Array
(
[some data] => some value
[type] => type1
)
)
 ...
)

Become
Array
(
[type1] => Array
(
[4] => Array
(
[data] => Array
(
[some data] => some value
[type] => type1
)
...
)
[12] ...
)
[type2] ...
)

Obviously, this is based on the possibility to do an extract on any
type of array, which is not the case, and that's what led me to my
final question on the combine.

But as I see your last answer, I suppose that it's not possible to
combine with default numeric keys.
I'll do a simple foreach.

On 5 mai, 04:03, "Dr. Loboto"  wrote:
> If you wantextract, do Set::extract(), if you want combine, do
> Set::combine(). I do not see sense in mixing them.
>
> On 4 май, 13:21, Gluckens  wrote:
>
>
>
>
>
>
>
> > This lead me to another question.
>
> > Is it possible to do a combine with default numeric key (0, 1, 2)
>
> > I was doing something like this :
> > $combine = Set::combine($result, '{n}.Data1.id', '{n}',
> > '{n}.Data2.name');
> > which return
> > Array
> > (
> >     [name1] => Array
> >         (
> >             [4] => Array
> >                 (
> >                     [some data] => some value
> >                 )
> >             [12] => Array
> >                 (
> >                     [some data] => some value
> >                 )
> >         )
> > )
>
> > But i'll like to get default numeric key instead of {n}.Data1.id
> > Something like :
> > Array
> > (
> >     [name1] => Array
> >         (
> >             [0] => Array
> >                 (
> >                     [some data] => some values
> >                 )
> >             [1] => Array
> >                 (
> >                     [some data] => some values
> >                 )
> >         )
> > )
>
> > I know that at this point I could simply do a foreach, but it could be
> > useful to know.
> > Thanks in advance.
>
> > On 4 mai, 10:46, Gluckens  wrote:
>
> > > Really?
>
> > > I was doing anextracton a previous combine which put the ID as the
> > > numeric key.
> > > But, switching it with a 0 and now everything seems to work.
>
> > > Still, it's strange that when I add another element with random key,
> > > it's now working.
>
> > > Anyway, I'll find an alternative for my ids.
>
> > > Thanks for the reply.
>
> > > On 4 mai, 08:01, "Dr. Loboto"  wrote:
>
> > > > Set::extract("/Some/thing", $data) assumes that you have true list -
> > > > array with numeric keys 0, 1, 2, ... - but not an associative array
> > > > with keys "some", "thing", ... or 4, 2, 15, ...
>
> > > > If you call it as Set::extract("/Some/thing", array_values($data))
> > > > when $data is associative array it will pass.
>
> > > > On 3 май, 16:21, Gluckens  wrote:
>
> > > > > Of course I know how to do it whithout theextractmethod.
>
> > > > > The point is, if theextractis not always working, it's not really
> > > > > usable cause you never know when it will break your things
>
> > > > > Someone points me to this ticket which could be 
> > > > > relatedhttp://cakephp.lighthouseapp.com/projects/42648/tickets/104-testpatch...
>
> > > > > But anyway, this fix would probably not be coming soon
>
> > > > > Seems like I'll need to rewrite large parts of code... ugh
>
> > > > > On 2 mai, 19:51, Otavio Martins Salomao 
> > > > > wrote:
>
> > > > > > u try this!
> > > > > > foreach($test as $element)
> > > > > >      $result = $element['Deep1']['Deep2']['extract'];
>
> > > > > > 2011/5/2 Gluckens 
>
> > > > > > > Hi everyone,
>
> > > > > > > I'm trying toextractdata from an array containing only one element
> > > > > > > and it doesn't seem to work properly.
> > > > > > > Here's an example :
>
> > > > > > > Starting array
> > > > > > > $test = array(4 => array('Deep1' => array('data1' => 'nothing',
> > > > > > > 'Deep2' => array('extract' => 1;
> > > > > > > Array
> > > > > > > (
> > > > > > >    [4] => Array
> > > > > > >        (
> > > > > > >            [Deep1] => Array
> > > > > > >                (
> > > > > > >       

Re: Set::extract on an array containing one element

2011-05-05 Thread Dr. Loboto
If you want extract, do Set::extract(), if you want combine, do
Set::combine(). I do not see sense in mixing them.

On 4 май, 13:21, Gluckens  wrote:
> This lead me to another question.
>
> Is it possible to do a combine with default numeric key (0, 1, 2)
>
> I was doing something like this :
> $combine = Set::combine($result, '{n}.Data1.id', '{n}',
> '{n}.Data2.name');
> which return
> Array
> (
>     [name1] => Array
>         (
>             [4] => Array
>                 (
>                     [some data] => some value
>                 )
>             [12] => Array
>                 (
>                     [some data] => some value
>                 )
>         )
> )
>
> But i'll like to get default numeric key instead of {n}.Data1.id
> Something like :
> Array
> (
>     [name1] => Array
>         (
>             [0] => Array
>                 (
>                     [some data] => some values
>                 )
>             [1] => Array
>                 (
>                     [some data] => some values
>                 )
>         )
> )
>
> I know that at this point I could simply do a foreach, but it could be
> useful to know.
> Thanks in advance.
>
> On 4 mai, 10:46, Gluckens  wrote:
>
>
>
>
>
>
>
> > Really?
>
> > I was doing an extract on a previous combine which put the ID as the
> > numeric key.
> > But, switching it with a 0 and now everything seems to work.
>
> > Still, it's strange that when I add another element with random key,
> > it's now working.
>
> > Anyway, I'll find an alternative for my ids.
>
> > Thanks for the reply.
>
> > On 4 mai, 08:01, "Dr. Loboto"  wrote:
>
> > > Set::extract("/Some/thing", $data) assumes that you have true list -
> > > array with numeric keys 0, 1, 2, ... - but not an associative array
> > > with keys "some", "thing", ... or 4, 2, 15, ...
>
> > > If you call it as Set::extract("/Some/thing", array_values($data))
> > > when $data is associative array it will pass.
>
> > > On 3 май, 16:21, Gluckens  wrote:
>
> > > > Of course I know how to do it whithout the extract method.
>
> > > > The point is, if the extract is not always working, it's not really
> > > > usable cause you never know when it will break your things
>
> > > > Someone points me to this ticket which could be 
> > > > relatedhttp://cakephp.lighthouseapp.com/projects/42648/tickets/104-testpatch...
>
> > > > But anyway, this fix would probably not be coming soon
>
> > > > Seems like I'll need to rewrite large parts of code... ugh
>
> > > > On 2 mai, 19:51, Otavio Martins Salomao 
> > > > wrote:
>
> > > > > u try this!
> > > > > foreach($test as $element)
> > > > >      $result = $element['Deep1']['Deep2']['extract'];
>
> > > > > 2011/5/2 Gluckens 
>
> > > > > > Hi everyone,
>
> > > > > > I'm trying to extract data from an array containing only one element
> > > > > > and it doesn't seem to work properly.
> > > > > > Here's an example :
>
> > > > > > Starting array
> > > > > > $test = array(4 => array('Deep1' => array('data1' => 'nothing',
> > > > > > 'Deep2' => array('extract' => 1;
> > > > > > Array
> > > > > > (
> > > > > >    [4] => Array
> > > > > >        (
> > > > > >            [Deep1] => Array
> > > > > >                (
> > > > > >                    [data1] => nothing
> > > > > >                    [Deep2] => Array
> > > > > >                        (
> > > > > >                            [extract] => 1
> > > > > >                        )
> > > > > >                )
> > > > > >        )
> > > > > > )
>
> > > > > > Set::extract('/Deep1/Deep2[extract=1]', $test);
> > > > > > NOT CORRECT
> > > > > > Array
> > > > > > (
> > > > > > )
>
> > > > > > But, when I add another element, let's say
> > > > > > $test[12] = array();
> > > > > > It works fine
> > > > > > Set::extract('/Deep1/Deep2[extract=1]', $test);
> > > > > > CORRECT
> > > > > > Array
> > > > > > (
> > > > > >    [0] => Array
> > > > > >        (
> > > > > >            [Deep2] => Array
> > > > > >                (
> > > > > >                    [extract] => 1
> > > > > >                )
> > > > > >        )
> > > > > > )
>
> > > > > > Am I using it properly?
> > > > > > Thanks in advance for any help.
>
> > > > > > --
> > > > > > Our newest site for the community: CakePHP Video Tutorials
> > > > > >http://tv.cakephp.org
> > > > > > Check out the new CakePHP Questions 
> > > > > > sitehttp://ask.cakephp.organdhelp
> > > > > > 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
> > > > > > athttp://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.g

Re: Set::extract on an array containing one element

2011-05-05 Thread Dr. Loboto
Understand difference between list and associative array. $list =
array($a, $b, $c) is list and have keys 0, 1, 2. $hash = array(1=>$a,
2=>$b, 3=>$c) is associative array as have keys 1, 2, 3 - even if they
are numeric they are not properly ordered. If you add arbitrary value
to list as $list[12] = $d you turn it into associative array as it
have now keys 0, 1, 2, 12 - _not_ properly ordered numeric but
arbitrary ones.

On 4 май, 10:46, Gluckens  wrote:
> Really?
>
> I was doing an extract on a previous combine which put the ID as the
> numeric key.
> But, switching it with a 0 and now everything seems to work.
>
> Still, it's strange that when I add another element with random key,
> it's now working.
>
> Anyway, I'll find an alternative for my ids.
>
> Thanks for the reply.
>
> On 4 mai, 08:01, "Dr. Loboto"  wrote:
>
>
>
>
>
>
>
> > Set::extract("/Some/thing", $data) assumes that you have true list -
> > array with numeric keys 0, 1, 2, ... - but not an associative array
> > with keys "some", "thing", ... or 4, 2, 15, ...
>
> > If you call it as Set::extract("/Some/thing", array_values($data))
> > when $data is associative array it will pass.
>
> > On 3 май, 16:21, Gluckens  wrote:
>
> > > Of course I know how to do it whithout the extract method.
>
> > > The point is, if the extract is not always working, it's not really
> > > usable cause you never know when it will break your things
>
> > > Someone points me to this ticket which could be 
> > > relatedhttp://cakephp.lighthouseapp.com/projects/42648/tickets/104-testpatch...
>
> > > But anyway, this fix would probably not be coming soon
>
> > > Seems like I'll need to rewrite large parts of code... ugh
>
> > > On 2 mai, 19:51, Otavio Martins Salomao 
> > > wrote:
>
> > > > u try this!
> > > > foreach($test as $element)
> > > >      $result = $element['Deep1']['Deep2']['extract'];
>
> > > > 2011/5/2 Gluckens 
>
> > > > > Hi everyone,
>
> > > > > I'm trying to extract data from an array containing only one element
> > > > > and it doesn't seem to work properly.
> > > > > Here's an example :
>
> > > > > Starting array
> > > > > $test = array(4 => array('Deep1' => array('data1' => 'nothing',
> > > > > 'Deep2' => array('extract' => 1;
> > > > > Array
> > > > > (
> > > > >    [4] => Array
> > > > >        (
> > > > >            [Deep1] => Array
> > > > >                (
> > > > >                    [data1] => nothing
> > > > >                    [Deep2] => Array
> > > > >                        (
> > > > >                            [extract] => 1
> > > > >                        )
> > > > >                )
> > > > >        )
> > > > > )
>
> > > > > Set::extract('/Deep1/Deep2[extract=1]', $test);
> > > > > NOT CORRECT
> > > > > Array
> > > > > (
> > > > > )
>
> > > > > But, when I add another element, let's say
> > > > > $test[12] = array();
> > > > > It works fine
> > > > > Set::extract('/Deep1/Deep2[extract=1]', $test);
> > > > > CORRECT
> > > > > Array
> > > > > (
> > > > >    [0] => Array
> > > > >        (
> > > > >            [Deep2] => Array
> > > > >                (
> > > > >                    [extract] => 1
> > > > >                )
> > > > >        )
> > > > > )
>
> > > > > Am I using it properly?
> > > > > Thanks in advance for any help.
>
> > > > > --
> > > > > Our newest site for the community: CakePHP Video Tutorials
> > > > >http://tv.cakephp.org
> > > > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
> > > > > 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
> > > > > athttp://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: Set::extract on an array containing one element

2011-05-04 Thread Gluckens
This lead me to another question.

Is it possible to do a combine with default numeric key (0, 1, 2)

I was doing something like this :
$combine = Set::combine($result, '{n}.Data1.id', '{n}',
'{n}.Data2.name');
which return
Array
(
[name1] => Array
(
[4] => Array
(
[some data] => some value
)
[12] => Array
(
[some data] => some value
)
)
)

But i'll like to get default numeric key instead of {n}.Data1.id
Something like :
Array
(
[name1] => Array
(
[0] => Array
(
[some data] => some values
)
[1] => Array
(
[some data] => some values
)
)
)

I know that at this point I could simply do a foreach, but it could be
useful to know.
Thanks in advance.

On 4 mai, 10:46, Gluckens  wrote:
> Really?
>
> I was doing an extract on a previous combine which put the ID as the
> numeric key.
> But, switching it with a 0 and now everything seems to work.
>
> Still, it's strange that when I add another element with random key,
> it's now working.
>
> Anyway, I'll find an alternative for my ids.
>
> Thanks for the reply.
>
> On 4 mai, 08:01, "Dr. Loboto"  wrote:
>
>
>
>
>
>
>
> > Set::extract("/Some/thing", $data) assumes that you have true list -
> > array with numeric keys 0, 1, 2, ... - but not an associative array
> > with keys "some", "thing", ... or 4, 2, 15, ...
>
> > If you call it as Set::extract("/Some/thing", array_values($data))
> > when $data is associative array it will pass.
>
> > On 3 май, 16:21, Gluckens  wrote:
>
> > > Of course I know how to do it whithout the extract method.
>
> > > The point is, if the extract is not always working, it's not really
> > > usable cause you never know when it will break your things
>
> > > Someone points me to this ticket which could be 
> > > relatedhttp://cakephp.lighthouseapp.com/projects/42648/tickets/104-testpatch...
>
> > > But anyway, this fix would probably not be coming soon
>
> > > Seems like I'll need to rewrite large parts of code... ugh
>
> > > On 2 mai, 19:51, Otavio Martins Salomao 
> > > wrote:
>
> > > > u try this!
> > > > foreach($test as $element)
> > > >      $result = $element['Deep1']['Deep2']['extract'];
>
> > > > 2011/5/2 Gluckens 
>
> > > > > Hi everyone,
>
> > > > > I'm trying to extract data from an array containing only one element
> > > > > and it doesn't seem to work properly.
> > > > > Here's an example :
>
> > > > > Starting array
> > > > > $test = array(4 => array('Deep1' => array('data1' => 'nothing',
> > > > > 'Deep2' => array('extract' => 1;
> > > > > Array
> > > > > (
> > > > >    [4] => Array
> > > > >        (
> > > > >            [Deep1] => Array
> > > > >                (
> > > > >                    [data1] => nothing
> > > > >                    [Deep2] => Array
> > > > >                        (
> > > > >                            [extract] => 1
> > > > >                        )
> > > > >                )
> > > > >        )
> > > > > )
>
> > > > > Set::extract('/Deep1/Deep2[extract=1]', $test);
> > > > > NOT CORRECT
> > > > > Array
> > > > > (
> > > > > )
>
> > > > > But, when I add another element, let's say
> > > > > $test[12] = array();
> > > > > It works fine
> > > > > Set::extract('/Deep1/Deep2[extract=1]', $test);
> > > > > CORRECT
> > > > > Array
> > > > > (
> > > > >    [0] => Array
> > > > >        (
> > > > >            [Deep2] => Array
> > > > >                (
> > > > >                    [extract] => 1
> > > > >                )
> > > > >        )
> > > > > )
>
> > > > > Am I using it properly?
> > > > > Thanks in advance for any help.
>
> > > > > --
> > > > > Our newest site for the community: CakePHP Video Tutorials
> > > > >http://tv.cakephp.org
> > > > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
> > > > > 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
> > > > > athttp://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: Set::extract on an array containing one element

2011-05-04 Thread Gluckens
Really?

I was doing an extract on a previous combine which put the ID as the
numeric key.
But, switching it with a 0 and now everything seems to work.

Still, it's strange that when I add another element with random key,
it's now working.

Anyway, I'll find an alternative for my ids.

Thanks for the reply.



On 4 mai, 08:01, "Dr. Loboto"  wrote:
> Set::extract("/Some/thing", $data) assumes that you have true list -
> array with numeric keys 0, 1, 2, ... - but not an associative array
> with keys "some", "thing", ... or 4, 2, 15, ...
>
> If you call it as Set::extract("/Some/thing", array_values($data))
> when $data is associative array it will pass.
>
> On 3 май, 16:21, Gluckens  wrote:
>
>
>
>
>
>
>
> > Of course I know how to do it whithout the extract method.
>
> > The point is, if the extract is not always working, it's not really
> > usable cause you never know when it will break your things
>
> > Someone points me to this ticket which could be 
> > relatedhttp://cakephp.lighthouseapp.com/projects/42648/tickets/104-testpatch...
>
> > But anyway, this fix would probably not be coming soon
>
> > Seems like I'll need to rewrite large parts of code... ugh
>
> > On 2 mai, 19:51, Otavio Martins Salomao 
> > wrote:
>
> > > u try this!
> > > foreach($test as $element)
> > >      $result = $element['Deep1']['Deep2']['extract'];
>
> > > 2011/5/2 Gluckens 
>
> > > > Hi everyone,
>
> > > > I'm trying to extract data from an array containing only one element
> > > > and it doesn't seem to work properly.
> > > > Here's an example :
>
> > > > Starting array
> > > > $test = array(4 => array('Deep1' => array('data1' => 'nothing',
> > > > 'Deep2' => array('extract' => 1;
> > > > Array
> > > > (
> > > >    [4] => Array
> > > >        (
> > > >            [Deep1] => Array
> > > >                (
> > > >                    [data1] => nothing
> > > >                    [Deep2] => Array
> > > >                        (
> > > >                            [extract] => 1
> > > >                        )
> > > >                )
> > > >        )
> > > > )
>
> > > > Set::extract('/Deep1/Deep2[extract=1]', $test);
> > > > NOT CORRECT
> > > > Array
> > > > (
> > > > )
>
> > > > But, when I add another element, let's say
> > > > $test[12] = array();
> > > > It works fine
> > > > Set::extract('/Deep1/Deep2[extract=1]', $test);
> > > > CORRECT
> > > > Array
> > > > (
> > > >    [0] => Array
> > > >        (
> > > >            [Deep2] => Array
> > > >                (
> > > >                    [extract] => 1
> > > >                )
> > > >        )
> > > > )
>
> > > > Am I using it properly?
> > > > Thanks in advance for any help.
>
> > > > --
> > > > Our newest site for the community: CakePHP Video Tutorials
> > > >http://tv.cakephp.org
> > > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
> > > > 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
> > > > athttp://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: Set::extract on an array containing one element

2011-05-04 Thread Dr. Loboto
Set::extract("/Some/thing", $data) assumes that you have true list -
array with numeric keys 0, 1, 2, ... - but not an associative array
with keys "some", "thing", ... or 4, 2, 15, ...

If you call it as Set::extract("/Some/thing", array_values($data))
when $data is associative array it will pass.

On 3 май, 16:21, Gluckens  wrote:
> Of course I know how to do it whithout the extract method.
>
> The point is, if the extract is not always working, it's not really
> usable cause you never know when it will break your things
>
> Someone points me to this ticket which could be 
> relatedhttp://cakephp.lighthouseapp.com/projects/42648/tickets/104-testpatch...
>
> But anyway, this fix would probably not be coming soon
>
> Seems like I'll need to rewrite large parts of code... ugh
>
> On 2 mai, 19:51, Otavio Martins Salomao 
> wrote:
>
>
>
>
>
>
>
> > u try this!
> > foreach($test as $element)
> >      $result = $element['Deep1']['Deep2']['extract'];
>
> > 2011/5/2 Gluckens 
>
> > > Hi everyone,
>
> > > I'm trying to extract data from an array containing only one element
> > > and it doesn't seem to work properly.
> > > Here's an example :
>
> > > Starting array
> > > $test = array(4 => array('Deep1' => array('data1' => 'nothing',
> > > 'Deep2' => array('extract' => 1;
> > > Array
> > > (
> > >    [4] => Array
> > >        (
> > >            [Deep1] => Array
> > >                (
> > >                    [data1] => nothing
> > >                    [Deep2] => Array
> > >                        (
> > >                            [extract] => 1
> > >                        )
> > >                )
> > >        )
> > > )
>
> > > Set::extract('/Deep1/Deep2[extract=1]', $test);
> > > NOT CORRECT
> > > Array
> > > (
> > > )
>
> > > But, when I add another element, let's say
> > > $test[12] = array();
> > > It works fine
> > > Set::extract('/Deep1/Deep2[extract=1]', $test);
> > > CORRECT
> > > Array
> > > (
> > >    [0] => Array
> > >        (
> > >            [Deep2] => Array
> > >                (
> > >                    [extract] => 1
> > >                )
> > >        )
> > > )
>
> > > Am I using it properly?
> > > Thanks in advance for any help.
>
> > > --
> > > Our newest site for the community: CakePHP Video Tutorials
> > >http://tv.cakephp.org
> > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
> > > 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
> > > athttp://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: Set::extract on an array containing one element

2011-05-03 Thread Gluckens
Of course I know how to do it whithout the extract method.

The point is, if the extract is not always working, it's not really
usable cause you never know when it will break your things

Someone points me to this ticket which could be related
http://cakephp.lighthouseapp.com/projects/42648/tickets/104-testpatch-setextract-returns-wrong-result-key-when-there-are-two-arrays-at-the-same-level

But anyway, this fix would probably not be coming soon

Seems like I'll need to rewrite large parts of code... ugh

On 2 mai, 19:51, Otavio Martins Salomao 
wrote:
> u try this!
> foreach($test as $element)
>      $result = $element['Deep1']['Deep2']['extract'];
>
> 2011/5/2 Gluckens 
>
>
>
>
>
>
>
> > Hi everyone,
>
> > I'm trying to extract data from an array containing only one element
> > and it doesn't seem to work properly.
> > Here's an example :
>
> > Starting array
> > $test = array(4 => array('Deep1' => array('data1' => 'nothing',
> > 'Deep2' => array('extract' => 1;
> > Array
> > (
> >    [4] => Array
> >        (
> >            [Deep1] => Array
> >                (
> >                    [data1] => nothing
> >                    [Deep2] => Array
> >                        (
> >                            [extract] => 1
> >                        )
> >                )
> >        )
> > )
>
> > Set::extract('/Deep1/Deep2[extract=1]', $test);
> > NOT CORRECT
> > Array
> > (
> > )
>
> > But, when I add another element, let's say
> > $test[12] = array();
> > It works fine
> > Set::extract('/Deep1/Deep2[extract=1]', $test);
> > CORRECT
> > Array
> > (
> >    [0] => Array
> >        (
> >            [Deep2] => Array
> >                (
> >                    [extract] => 1
> >                )
> >        )
> > )
>
> > Am I using it properly?
> > Thanks in advance for any help.
>
> > --
> > Our newest site for the community: CakePHP Video Tutorials
> >http://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd 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
> > athttp://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: Set::extract on an array containing one element

2011-05-03 Thread gremlin
@Otavio - that has nothing to do with the question.

On May 2, 7:51 pm, Otavio Martins Salomao 
wrote:
> u try this!
> foreach($test as $element)
>      $result = $element['Deep1']['Deep2']['extract'];
>
> 2011/5/2 Gluckens 
>
>
>
>
>
>
>
> > Hi everyone,
>
> > I'm trying to extract data from an array containing only one element
> > and it doesn't seem to work properly.
> > Here's an example :
>
> > Starting array
> > $test = array(4 => array('Deep1' => array('data1' => 'nothing',
> > 'Deep2' => array('extract' => 1;
> > Array
> > (
> >    [4] => Array
> >        (
> >            [Deep1] => Array
> >                (
> >                    [data1] => nothing
> >                    [Deep2] => Array
> >                        (
> >                            [extract] => 1
> >                        )
> >                )
> >        )
> > )
>
> > Set::extract('/Deep1/Deep2[extract=1]', $test);
> > NOT CORRECT
> > Array
> > (
> > )
>
> > But, when I add another element, let's say
> > $test[12] = array();
> > It works fine
> > Set::extract('/Deep1/Deep2[extract=1]', $test);
> > CORRECT
> > Array
> > (
> >    [0] => Array
> >        (
> >            [Deep2] => Array
> >                (
> >                    [extract] => 1
> >                )
> >        )
> > )
>
> > Am I using it properly?
> > Thanks in advance for any help.
>
> > --
> > Our newest site for the community: CakePHP Video Tutorials
> >http://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd 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
> > athttp://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: Set::extract on an array containing one element

2011-05-02 Thread Otavio Martins Salomao
u try this!
foreach($test as $element)
 $result = $element['Deep1']['Deep2']['extract'];

2011/5/2 Gluckens 

> Hi everyone,
>
> I'm trying to extract data from an array containing only one element
> and it doesn't seem to work properly.
> Here's an example :
>
> Starting array
> $test = array(4 => array('Deep1' => array('data1' => 'nothing',
> 'Deep2' => array('extract' => 1;
> Array
> (
>[4] => Array
>(
>[Deep1] => Array
>(
>[data1] => nothing
>[Deep2] => Array
>(
>[extract] => 1
>)
>)
>)
> )
>
> Set::extract('/Deep1/Deep2[extract=1]', $test);
> NOT CORRECT
> Array
> (
> )
>
> But, when I add another element, let's say
> $test[12] = array();
> It works fine
> Set::extract('/Deep1/Deep2[extract=1]', $test);
> CORRECT
> Array
> (
>[0] => Array
>(
>[Deep2] => Array
>(
>[extract] => 1
>)
>)
> )
>
> Am I using it properly?
> Thanks in advance for any help.
>
> --
> 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


Set::extract on an array containing one element

2011-05-02 Thread Gluckens
Hi everyone,

I'm trying to extract data from an array containing only one element
and it doesn't seem to work properly.
Here's an example :

Starting array
$test = array(4 => array('Deep1' => array('data1' => 'nothing',
'Deep2' => array('extract' => 1;
Array
(
[4] => Array
(
[Deep1] => Array
(
[data1] => nothing
[Deep2] => Array
(
[extract] => 1
)
)
)
)

Set::extract('/Deep1/Deep2[extract=1]', $test);
NOT CORRECT
Array
(
)

But, when I add another element, let's say
$test[12] = array();
It works fine
Set::extract('/Deep1/Deep2[extract=1]', $test);
CORRECT
Array
(
[0] => Array
(
[Deep2] => Array
(
[extract] => 1
)
)
)

Am I using it properly?
Thanks in advance for any help.

-- 
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