Can you explain what you are trying to do? I'm not sure I get it from your 
code example.

On Monday, April 14, 2014 11:31:42 AM UTC+2, bato wrote:
>
> Hi,
>
> I'm trying to figure out if it's possible to use formatResults in custom 
> finder methods to use ORM chain. I have seen in docs the example with 
> mapper reducer.
>
> In my table object i have
>
> public findFlat($query, $options = []) {
>        return $query->formatResults(function($results, $query) {
>             return $results->map(function($row) {
>                 foreach ($row['content']->toArray() as $key => $value) {
>                     $row[$key] = $value;
>                 }
>                 unset($row['content']);
>                 return $row;
>             });
>         });
> }
>
> then in my controller I have
>
> $images = TableRegistry::get('ImageObjects');
> $result = $images->find('flat');
> $result->contain(['Contents', 'Streams']);
> debug($result->toArray());
>
> In this way it works but if I add first()
>
> $result->first();
>
> then I obtain a fatal error in findFlat() method
>
> Error: Call to a member function toArray() on a non-object
>
> Any help? 
> Am I using wrong formatResults()? Is it possible to chain only mapper 
> reducer?
>
> thanks
> alberto
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to