Re: Set::extract on an array containing one element
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 > > > >
Re: Set::extract on an array containing one element
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] =
Re: Set::extract on an array containing one element
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
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
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
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
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
@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
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
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
Set::extract('/Model/AssociatedModel[field=xxx]/..') extracts wrong data
I have written a test to show this issue - http://bin.cakephp.org/view/1661821360 Instead of selecting Model with AssociatedModel that matched the condition, it seems to extract first n Models where n is the count of AssociatedModels matching the condition. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Error in results when using Set::Extract on a set containing calculated fields
While experimenting with Set::extract I ran into an situation where I'm getting, what appears to be, incorrect results on the first element (index 0) when using a back reference (i.e. "/x/..") in the path when the set contains a calculated field. Here is a simplified example to provide context: The data set after calling Model->find(...) to get records with a calculated field (i.e. "age") $a = array( [0] => array( [Person] => array( [name]=>Test 1, [score]=>4 ), [0] => array( [age] => 20 ) ), [1] => array( [Person] => array( [name]=>Test 2, [score]=>5 ), [0] => array( [age] => 21 ) ), [2] => array( [Person] => array( [name]=>Test 3, [score]=>3 ), [0] => array( [age] => 22 ) ), [3] => array( [Person] => array( [name]=>Test 4, [score]=>2 ), [0] => array( [age] => 16 ) ) ); If I do something like this: $b = Set::extract('/0[age>19]/..', $a); or $b = Set::extract( '/Person[score>2]/..', $a); I get this: Array ( [0] => Array ( [age] => 20 ) [1] => Array ( [Person] => Array ( [name] => Test 2 [score] => 5 ) [0] => Array ( [age] => 21 ) ) [2] => Array ( [Person] => Array ( [name] => Test 3 [score] => 3 ) [0] => Array ( [age] => 22 ) ) ) Notice that the first item (at index 0 of the results returned from extract) has lost everything but the calculated field (which also has/ had an index of 0). If I put an empty element at the beginning of the data set ($a) (to bump everything up by 1 index number) by doing something like: array_unshift($a, array()) then I get the expected result which is: Array ( [0] => Array ( [Person] => Array ( [name] => Test 1 [score] => 4 ) [0] => Array ( [age] => 20 ) ) [1] => Array ( [Person] => Array ( [name] => Test 2 [score] => 5 ) [0] => Array ( [age] => 21 ) ) [2] => Array ( [Person] => Array ( [name] => Test 3 [score] => 3 ) [0] => Array ( [age] => 22 ) ) ) Similarly, if I omit the back reference and just do: $b = Set::extract( '/Person[score>2]', $a); I get the expected results (e.g. all "Person" data without the first item losing any info). It appears to me that if there is a calculated field (which, as expected, gets put into index 0 of the results returned from the find call); Set::extract gets confused when getting the parent data for the first item (at index 0) of the result set and erroneously returns the data at $a[0][0] rather than the actual/correct data at $a[0]. So, before I cry "bug", Is my usage and expectation of the results in such a situation correct? If not, what would be the correct way to implement this using Set::extract? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Set::extract and Set::combine - help needed
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" 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 >> [c
Re: Set::extract and Set::combine - help needed
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" 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 >
Set::extract and Set::combine - help needed
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 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Set::extract
Perfect, that worked a treat thank you! On Apr 13, 5:41 pm, grigri wrote: > This should do the trick: > > Set::combine($data, '{n}.title', '{n}.no_tags'); > > hth > grigri > > On Apr 13, 3:30 pm, "ross.hagg...@googlemail.com" > > wrote: > > Hi i have the following array > > > array( > > [0] => Array( > > [title] => Centeral Line Bundle > > [no_tags] => 2 > > ) > > > And i want to create the following. I'm trying to use the Tagcloud > > helper found in the Bakery. Someone mentioned i could use > > Set::extract, i've given it a try but no joy. I used pushDiff to > > merge no_tags and title together. Any help would be appreciated. > > > Ross > > > array( > > Centeral Line Bundle => 2, ... //Required for Tagcloud helper > > -http://bakery.cakephp.org/articles/view/tagcloud-helper --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Set::extract
This should do the trick: Set::combine($data, '{n}.title', '{n}.no_tags'); hth grigri On Apr 13, 3:30 pm, "ross.hagg...@googlemail.com" wrote: > Hi i have the following array > > array( > [0] => Array( > [title] => Centeral Line Bundle > [no_tags] => 2 > ) > > And i want to create the following. I'm trying to use the Tagcloud > helper found in the Bakery. Someone mentioned i could use > Set::extract, i've given it a try but no joy. I used pushDiff to > merge no_tags and title together. Any help would be appreciated. > > Ross > > array( > Centeral Line Bundle => 2, ... //Required for Tagcloud helper > -http://bakery.cakephp.org/articles/view/tagcloud-helper --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Set::extract
Hi i have the following array array( [0] => Array( [title] => Centeral Line Bundle [no_tags] => 2 ) And i want to create the following. I'm trying to use the Tagcloud helper found in the Bakery. Someone mentioned i could use Set::extract, i've given it a try but no joy. I used pushDiff to merge no_tags and title together. Any help would be appreciated. Ross array( Centeral Line Bundle => 2, ... //Required for Tagcloud helper - http://bakery.cakephp.org/articles/view/tagcloud-helper --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Set::extract() with threaded and associated data
Hi grigri, > If you paste the exact format of the data array you're trying to > process, I'm sure I can write the params for you to extrat it. ok, here goes: http://pastie.org/369383 thanks, j -- jon bennett w: http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Set::extract() with threaded and associated data
If you paste the exact format of the data array you're trying to process, I'm sure I can write the params for you to extrat it. Do a debug() or print_r() on the data [or a subset... enough to get the structure] and paste it here. hth grigri On Jan 23, 12:42 pm, Jon Bennett wrote: > hi, > > I'm sure this is possible, it's just alluding me at present! > > I have 2 models: > > MixtureCategory > Mixture > > MixtureCategory is a parent/child self association, so I'm getting the > data like so: > > $this->data = $this->MixtureCategory->find('threaded'); > > I'm looping over $this->data in my view, but only need to display info > about the top level category, and would like to output list of links > to all mixtures that belong to a second level category. > > foreach($this->data as $category): > > // name > echo $category['MixtureCategory']['name']; > > // mixtures > $mixtures = array_combine( > Set::extract($category, > 'children.{n}.MixtureCategory.{s}.Mixture.name'), > Set::extract($category, > 'children.{n}.MixtureCategory.{s}.Mixture.slug') > ); > > // test > debug($mixtures); > > endforeach; > > this gives me total garbage though. > > any ideas? > > cheers, > > Jon > > -- > > jon bennett > w:http://www.jben.net/ > iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Set::extract() with threaded and associated data
I am very unsure about this, but I believe you might be looking for Set::classicExtract() http://api.cakephp.org/class_set.html#e8412492e8a6c81939b4fb037043eaa3 Hope that helps! On Jan 23, 1:42 pm, Jon Bennett wrote: > hi, > > I'm sure this is possible, it's just alluding me at present! > > I have 2 models: > > MixtureCategory > Mixture > > MixtureCategory is a parent/child self association, so I'm getting the > data like so: > > $this->data = $this->MixtureCategory->find('threaded'); > > I'm looping over $this->data in my view, but only need to display info > about the top level category, and would like to output list of links > to all mixtures that belong to a second level category. > > foreach($this->data as $category): > > // name > echo $category['MixtureCategory']['name']; > > // mixtures > $mixtures = array_combine( > Set::extract($category, > 'children.{n}.MixtureCategory.{s}.Mixture.name'), > Set::extract($category, > 'children.{n}.MixtureCategory.{s}.Mixture.slug') > ); > > // test > debug($mixtures); > > endforeach; > > this gives me total garbage though. > > any ideas? > > cheers, > > Jon > > -- > > jon bennett > w:http://www.jben.net/ > iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Set::extract() with threaded and associated data
hi, I'm sure this is possible, it's just alluding me at present! I have 2 models: MixtureCategory Mixture MixtureCategory is a parent/child self association, so I'm getting the data like so: $this->data = $this->MixtureCategory->find('threaded'); I'm looping over $this->data in my view, but only need to display info about the top level category, and would like to output list of links to all mixtures that belong to a second level category. foreach($this->data as $category): // name echo $category['MixtureCategory']['name']; // mixtures $mixtures = array_combine( Set::extract($category, 'children.{n}.MixtureCategory.{s}.Mixture.name'), Set::extract($category, 'children.{n}.MixtureCategory.{s}.Mixture.slug') ); // test debug($mixtures); endforeach; this gives me total garbage though. any ideas? cheers, Jon -- jon bennett w: http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Set::extract is shuffling elements in the return array
On a hunch, I searched my code for "shuffle" and spotted a line where the array was indeed shuffled before Set::extract was called. Set::extract does in fact return elements in the same order. :-) RyOnLife wrote: > > Marcelo, I don't know any Java, however, just seems strange that it > shuffles the data. Even if it's "not ordered" and "not sorted", why > wouldn't it just return in the existing order? > > > > > Marcelo Andrade wrote: >> >> On Wed, Nov 5, 2008 at 11:46 PM, RyOnLife <[EMAIL PROTECTED]> >> wrote: >>> >>> Anyone else experienced this problem? How can I get the elements in >>> array >>> returned by Set::extract to be in the same order they're found in the >>> multi-dimensional array? >> >> I'm still a beginner with CakePHP, but I suppose >> that the concept behind a "Set" of things does not >> imply in any order. >> >> With an analogy, the "Set" interface in Java is >> called to be intrinsically "not ordered" and "not >> sorted". >> >> Best regards. >> >> -- >> MARCELO DE F. ANDRADE (aka "eleKtron") >> Belem, PA, Amazonia, Brazil >> Linux User #221105 >> >> [EMAIL PROTECTED] ~]# links http://pa.slackwarebrasil.org/ >> >> >> >> >> > > -- View this message in context: http://n2.nabble.com/Set%3A%3Aextract-is-shuffling-elements-in-the-return-array-tp1463184p1463557.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Set::extract is shuffling elements in the return array
Marcelo, I don't know any Java, however, just seems strange that it shuffles the data. Even if it's "not ordered" and "not sorted", why wouldn't it just return in the existing order? Marcelo Andrade wrote: > > On Wed, Nov 5, 2008 at 11:46 PM, RyOnLife <[EMAIL PROTECTED]> wrote: >> >> Anyone else experienced this problem? How can I get the elements in array >> returned by Set::extract to be in the same order they're found in the >> multi-dimensional array? > > I'm still a beginner with CakePHP, but I suppose > that the concept behind a "Set" of things does not > imply in any order. > > With an analogy, the "Set" interface in Java is > called to be intrinsically "not ordered" and "not > sorted". > > Best regards. > > -- > MARCELO DE F. ANDRADE (aka "eleKtron") > Belem, PA, Amazonia, Brazil > Linux User #221105 > > [EMAIL PROTECTED] ~]# links http://pa.slackwarebrasil.org/ > > > > > -- View this message in context: http://n2.nabble.com/Set%3A%3Aextract-is-shuffling-elements-in-the-return-array-tp1463184p1463527.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Set::extract is shuffling elements in the return array
On Wed, Nov 5, 2008 at 11:46 PM, RyOnLife <[EMAIL PROTECTED]> wrote: > > Anyone else experienced this problem? How can I get the elements in array > returned by Set::extract to be in the same order they're found in the > multi-dimensional array? I'm still a beginner with CakePHP, but I suppose that the concept behind a "Set" of things does not imply in any order. With an analogy, the "Set" interface in Java is called to be intrinsically "not ordered" and "not sorted". Best regards. -- MARCELO DE F. ANDRADE (aka "eleKtron") Belem, PA, Amazonia, Brazil Linux User #221105 [EMAIL PROTECTED] ~]# links http://pa.slackwarebrasil.org/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Set::extract is shuffling elements in the return array
I am using Set::extract to pull some IDs out of a large multi-dimensional array. Works great, except in the array that is returned, the IDs are shuffled. For example, the ID from the 0th dimension of the multi-dimensional array is the 3rd element in the return array. IDs are not returned in the same order, or even in the reverse order. They appear to be shuffled. Anyone else experienced this problem? How can I get the elements in array returned by Set::extract to be in the same order they're found in the multi-dimensional array? Thanks! -- View this message in context: http://n2.nabble.com/Set%3A%3Aextract-is-shuffling-elements-in-the-return-array-tp1463184p1463184.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Set::extract issue - array must start with [0] index
I have noticed this to. Forget to post a ticket for enhancements, my solution for now was to re-index the array. On Oct 25, 7:33 pm, senser <[EMAIL PROTECTED]> wrote: > Hello, > > I have problem using Set::extract class. Here is an example array > $test: > > Array > ( > [3181] => Array > ( > [Sync] => Array > ( > [id] => 3181 > [synced] => 0 > ) > ) > > On this array Set::extract('/Sync[id=3181]', $test) returns an empty > result but if I change the array like this > > Array > ( > [0] => Array > ( > ) > [3181] => Array > ( > [Sync] => Array > ( > [id] => 3181 > [synced] => 0 > ) > ) > > and Set::extract('/Sync[id=3181]', $test) gives the right result. My > conclusion is that Set:extract needs the first element of an array to > be with zero index - am I wrong or missing something. > > Thanks. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Set::extract issue - array must start with [0] index
Hello, I have problem using Set::extract class. Here is an example array $test: Array ( [3181] => Array ( [Sync] => Array ( [id] => 3181 [synced] => 0 ) ) On this array Set::extract('/Sync[id=3181]', $test) returns an empty result but if I change the array like this Array ( [0] => Array ( ) [3181] => Array ( [Sync] => Array ( [id] => 3181 [synced] => 0 ) ) and Set::extract('/Sync[id=3181]', $test) gives the right result. My conclusion is that Set:extract needs the first element of an array to be with zero index - am I wrong or missing something. Thanks. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Set::extract with multiple filters
Solved: $result = Set::extract('/Posts[author=pete][hidden=0]/.', :) note: this is not XPath conform... On Sep 24, 1:31 pm, leberle <[EMAIL PROTECTED]> wrote: > Hi dudes, > > I've a problem with Set::extract when using multiple filters. Lets say > i have an array $my_posts which contains a bunch of nested newspost- > arrays, and now i want all posts from an author named "pete" which are > not hidden: > > $result = Set::extract('/Posts[author=pete and hidden=0]/.', > $my_posts); > > For some reason this does not work (and $my_posts definitley contains > entries that would macht). With just one filter-statment it works > fine. > > Is the syntax correct? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Set::extract with multiple filters
Hi dudes, I've a problem with Set::extract when using multiple filters. Lets say i have an array $my_posts which contains a bunch of nested newspost- arrays, and now i want all posts from an author named "pete" which are not hidden: $result = Set::extract('/Posts[author=pete and hidden=0]/.', $my_posts); For some reason this does not work (and $my_posts definitley contains entries that would macht). With just one filter-statment it works fine. Is the syntax correct? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Set::extract, parents and ticket 5225
Hi! I have a tree structure like this: Array ( [0] => Array ( [Location] => Array ( [id] => 1 [parent_id] => [lft] => 1 [rght] => 32 [name_en] => Tokyo ... ) [children] => Array ( [0] => Array ( [Location] => Array ( [id] => 58 ... I'm trying to extract all children of the Location "Tokyo" and I expected to do it with the following Xpath: Set::extract('/Location[name_en=Tokyo]/../children', $data); But Set just gives me an undefined offset: 0 [CORE/cake/libs/set.php, line 403]. Seems ticket 5225 (https://trac.cakephp.org/ticket/5225) is not fixed yet after all? (trying this on very latest checkout 7573) Chrs, Dav --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Cakephp sessions -> Set::extract implementation of xpath issues
Hi all! I'm working on an tool that puts cakephp, red5 streaming server and oracle together. It all works ok, but the problem are the shared sessions between cake and red5. I've configured all the parameters to have the database ready to work with cake sessions, and i can see the contents of the cake_sessions.data column from my flash player. I've been merging on your code for a while and just see that it's constructed a try to simulate xpath through the Set::extract function... And I ask...Why implementing this from the beggining and not using xerces' apache plugin for php? I think it resolves all this nigthmare of sharing sessions between diferent platforms. There is an implementation for c++, java, perl, And a lot of extesions for many web servers like tomcat, apache, Maybe another idea is to have the sessions shared on the database with json notation instead of XPATH, but if you use XPATH you have to know that many databases have XPATH support integrated on their core, like for example oracle with its xmltype. It has a dedicated grammar to query xpath nodes. regards, mike --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Possible bug in Set::extract()
Nice find, fixed in: https://trac.cakephp.org/changeset/7546 On Aug 6, 6:53 am, XuMiX <[EMAIL PROTECTED]> wrote: > Array > ( > [0] => Array > ( > [Film] => Array > ( > [id] => 160 > ) > [Person] => Array > ( > [0] => Array > ( > [id] => 12 > [FilmsPerson] => Array > ( > [id] => 1 > [film_id] => 160 > [person_id] => 12 > [profession_id] => 3 > ) > > ) > > [1] => Array > ( > [id] => 47 > [FilmsPerson] => Array > ( > [id] => 2 > [film_id] => 160 > [person_id] => 47 > [profession_id] => 1 > ) > > ) > > [2] => Array > ( > [id] => 48 > [FilmsPerson] => Array > ( > [id] => 3 > [film_id] => 160 > [person_id] => 48 > [profession_id] => 4 > ) > > ) > > . > > After $ids = Set::extract($films, '/Person/ > FilmsPerson[profession_id=1]/..'); > pr($ids); > i got: > > Array > ( > [0] => Array > ( > [Person] => Array > ( > [id] => 12 > [FilmsPerson] => Array > ( > [id] => 1 > [film_id] => 160 > [person_id] => 12 > [profession_id] => 3 > ) > > ) > > ) > > [1] => Array > ( > [Person] => Array > ( > [id] => 12 > [FilmsPerson] => Array > ( > [id] => 1 > [film_id] => 160 > [person_id] => 12 > [profession_id] => 3 > ) > > ) > > ) > > [2] => Array > ( > [Person] => Array > ( > [id] => 12 > [FilmsPerson] => Array > ( > [id] => 1 > [film_id] => 160 > [person_id] => 12 > [profession_id] => 3 > ) > > ) > > ) > > But if i do $ids = Set::extract($films, '/Person/ > FilmsPerson[profession_id=1]'); I have elements with proper > profession_id... --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: I need help with Set::extract
Hi, Have a look at this, http://bakery.cakephp.org/articles/view/simpleresults-behavior-re-index-results-from-findall, its a behaviour for 1.2 that changes the indexing. If it doesn't do what you need, hopefully it will give you a place to start. Penfold On 4 Jul, 04:05, Ketan Patel <[EMAIL PROTECTED]> wrote: > The following is my array structure: > Array > ( > [0] => Array > ( > [0] => Array > ( > [TagCount] => 5 > ) > > [TagsPost] => Array > ( > [TagId] => 1 > ) > > [Tag] => Array > ( > [TagName] => personal > ) > > ) >[1] => Array > ( > [0] => Array > ( > [TagCount] => 3 > ) > > [TagsPost] => Array > ( > [TagId] => 3 > ) > > [Tag] => Array > ( > [TagName] => general > ) > > ) > ) > which I want to organize as follows > array > ( >[0] => Array( > [TagCount]=>5, > [TagId] =>1, > [TagName] => personal >) > [1] => Array( > [TagCount]=>3, > [TagId] =>3, > [TagName] => general > ) > ) > Using set I am able to extract tagcount, tagId and tagName separately > in individual array, but is there a way directly that could give me > what I want without coding manual loop. > > Cheers, > Ketan ;-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
I need help with Set::extract
The following is my array structure: Array ( [0] => Array ( [0] => Array ( [TagCount] => 5 ) [TagsPost] => Array ( [TagId] => 1 ) [Tag] => Array ( [TagName] => personal ) ) [1] => Array ( [0] => Array ( [TagCount] => 3 ) [TagsPost] => Array ( [TagId] => 3 ) [Tag] => Array ( [TagName] => general ) ) ) which I want to organize as follows array ( [0] => Array( [TagCount]=>5, [TagId] =>1, [TagName] => personal ) [1] => Array( [TagCount]=>3, [TagId] =>3, [TagName] => general ) ) Using set I am able to extract tagcount, tagId and tagName separately in individual array, but is there a way directly that could give me what I want without coding manual loop. Cheers, Ketan ;-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---