2

This is what I have at the moment:

$q = new ParseQuery("Artist");
$q->descending('createdAt');
$r = $q->find();
var_dump($r[0]->get('painting'));

However an Artist may have many Paintings. The result returned doesn't include any Paintings. Is it possible to retrieve all related data with a single query?

1 Answer 1

1

"In some situations, you want to return multiple types of related objects in one query. You can do this with the include method. For example, let's say you are retrieving the last ten comments, and you want to retrieve their related posts at the same time:"

Code specific

// Include the post data with each comment
query->includeKey(ColumnNameWithPointer);

Taken from the Parse Docs PHP

Sign up to request clarification or add additional context in comments.

5 Comments

I've tried that. But it throws an error field painting cannot be included because it is not a pointer to another object. From the Painting class, artist is a pointer. But from the Artist class, painting is a relation.
Maybe there's a problem with my data structure. But there's no example on how to implement a typical relational db with Parse. Would be good to have some tips on designing the db.
Sorry I'm so late with my response, but how do you save the pointer to an object? Do you save it by saving the object itself, in this case the painting object. or do you save it with an array of ID's of the objects you're referring to?
No worries. I'm not sure how the db in parse works and how it's built. We're new to this platform and it was my colleague who did the initial structure. I'm not sure how he did it though. I'm building my own classes and saving them programmatically to see what kind of structure it will result in Parse. But that'll be after the weekends :).
Ah that wouldn't be a problem, my Parse app also uses custom classes, so that wouldn't be a problem. If you'd like we could start a chat if you need some help somewhere today :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.