Wednesday, June 30, 2010

Re: find output array!

Oh, this soultion seems to be fine, but there is some additional
problem. In fact my array is something like the following:

Array
(
[0] => Array
(
[0] => Array
(
[Category] => Array
(
[id] => 1
[parent_id] => 0
[name] => Arts
[description] => Arts of Oh!
)

)

[1] => Array
(
[Category] => Array
(
[id] => 5
[parent_id] => 0
[name] => Electronics
[description] => Electronics cats!
)

)

[2] => Array
(
[Category] => Array
(
[id] => 6
[parent_id] => 0
[name] => Cars
[description] =>

The car and driving!!

)

)

)

[1] => Array
(
[0] => Array
(
[Category] => Array
(
[id] => 2
[parent_id] => 1
[name] => Painting
[description] =>

The art of Painting!

)

)

[1] => Array
(
[Category] => Array
(
[id] => 8
[parent_id] => 1
[name] => Photography
[description] =>

Photographs Images!

)

)

)

[2] => Array
(
[0] => Array
(
[Category] => Array
(
[id] => 9
[parent_id] => 2
[name] => Classical
[description] =>

Classical Paintings!!

)

)

)

[5] => Array
(
[0] => Array
(
[Category] => Array
(
[id] => 7
[parent_id] => 5
[name] => TVs
[description] =>

The watching of TVs.

)

)

)

)

It displays array of parent - child category architecture, built on
adjacent approach - http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
-

In this array, the first numerical key represents each category id
which has childs categories. The second numerical key, represents the
incremental value returned by find all which handles the number of
record. What I want to achive is to replace the last numerical value
with the id of each category . For example, consider the last element
of the above array:

[5] => Array
(
[0] => Array
(
[Category] => Array
(
[id] => 7
[parent_id] => 5
[name] => TVs
[description] =>

The watching of TVs.

I want it to be like - Notice the number 7 -:

[5] => Array
(
[7] => Array
(
[Category] => Array
(
[id] => 7
[parent_id] => 5
[name] => TVs
[description] =>

The watching of TVs.

I think Set::combine does not support something like:

$outPut = Set::combine($outPut, '{n}.{n}','{n}.{n}.Category.id');

This is because the path includes two numerical value in its route.

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

No comments: