no way to do that in PHP, afaik. the { } string operators will not
operate on a function.

However if you add something like this to your app_controller;

[code]

        function get($data, $member) {
                if (!is_array($member)) {
                        $member = explode('.', $member);
                }
                foreach($member as $m) {
                        if (isset($data[$m])) {
                                $data = $data[$m];
                        } else {
                                trigger_error("Oups! There is no '$m' defined! 
(req:
'".implode('.',$member)."')",E_USER_NOTICE);
                                break;
                        }
                }
                return $data;
        }
[/code]


You'll be able to do something like this;

$foo = $this->get($this->User->findbyId('3'),'User.name');

and.. for efficiency's sake, you could do something like this instead;
extracts only the username... instead of the whole user obj...
$foo = $this->get($this->User-
>findbyId('3',array('name')),'User.name');


Hope this helps!

Seb.


On Apr 7, 5:33 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> when code in cake,I always encounter the situation $this->User-
>
> >findById('3')['User']['name'] ,something like that.
>
> but it doesn't work.I know.I used to coding like this :$foo = 
> $this->User->findById('3'); $foo['User']['name'],but I am really tired of
>
> that .
>
> so what really need to be done in php?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to