FriendsOfCake/cakephp-csvview

Outputting recursive belongsTo associations

Closed this issue · 4 comments

Hi Jose,

I've been having issues trying to output recursive belongsTo associations using your plugin.

In the query below all the data pulled from the database is available except for items in the 'User' array

$results = $this->Payment->find('all', array(
       'contain' => array(
           'Invoice'=>
               array('Client'=>
                   array('User')

               ),
       )
   ));

Is this something that is supported?

So internally, it just uses Hash::extract() to get a single value

Maybe you could test your data via something like:

$value = Hash::extract($results, 'Invoice.Client.{n}.User');

Might want to play with that syntax. If there is a value for $value[0], then that will be used in the output.

seems to hand back an empty array.

Though If I print the array before it's serialised all the data is as it should be.

You will want to play with that syntax. For example, try something simple:

Set::extract($results, 'LayerOne');

Then go down further:

Set::extract($results, 'LayerOne.LayerTwo');

The hash class is a CakePHP class. Docs are here:
http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html

On Thu, Nov 7, 2013 at 4:57 PM, JacobGriffiths notifications@github.comwrote:

seems to hand back an empty array.

Though If I print the array before it's serialised all the data is as it
should be.


Reply to this email directly or view it on GitHubhttps://github.com//issues/22#issuecomment-28010597
.

Closing, as this isn't a bug with the plugin, but a question about how the data is extracted in a user's application.