I have some data that is the result of a stored procedure call that
I'm struggling to re-shape into a more desirable array. One of the
selected columns is the result of a CASE block which checks values
from a couple of tables, returning the appropriate field. As such,
Cake can't give me a model key and puts it under "0" (zero). I'd like
to move the value under that to inside the other array.
This appears so simple, yet I've tried--and failed--with all sorts of
Set::extract/merge/combine ... er, combinations. I know I can use
map() but creating a callback seems like overkill for something that
will *never* be used anywhere else in the app. I could do it in a
foreach loop with a tmp array but, well, what's the point of that?
Let's have a look:
Array
(
[0] => Array
(
[Model] => Array
(
[id] => 227
)
[0] => Array
(
[foo] => some string // <- my CASE block field
)
)
[1] => Array
(
[Model] => Array
(
[id] => 228
)
[0] => Array
(
[foo] => some other string
)
)
// etc ...
I'd like it to be in this form:
Array
(
[0] => Array
(
[Model] => Array
(
[id] => 227
[foo] => some string
)
)
[1] => Array
(
[Model] => Array
(
[id] => 228
[foo] => some other string
)
Can anyone point me in the right direction? I'm sure this is a Set
class one-liner.
btw, I've grown to love the Set class but have yet to see a clear
explanation of the params that Set::combine takes. I've seen examples
here on the list but have never been able to figure out what makes
them work. I'd really appreciate a clue on that.
--~--~---------~--~----~------------~-------~--~----~
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:
Post a Comment