Php OR query not working?

Hey there!
When I run this php query on a web page it’s not working. It OR’s some of the db rows, but not all. What I get is somewhat OR and somewhat an AND…
Any idea why?

$query0 = new BackendlessDataQuery();
$where0 = "friend_id = '" . $user_id . "' or user_id = '" . $user_id . "'";
$friends = Backendless::$Data->of("Friends")->find($query0)->getAsClass();

Hi Juha,

Please provide your dataset and a query with exact values, so that we could test it with REST and PHP and see that results are different.

Sure will, but could you be more specific what I should you and where?

I mean, we need a way to reproduce your problem in order to confirm and fix it. So I am asking you to provide an exact where clause, like $where0 = “friend_id = ‘123466’ or user_id = ‘12345’”;, your application credentials (app id and secret key) and the data, on which the issue would reproduce (you may export your own from console). Ideally, you would send a minimal sample application, which does the same. You may publish it here or send to

Please check whether the following code would work as expected or not:

$query0 = new BackendlessDataQuery();
$where0 = "friend_id = '1049C5F5-9E7A-A984-FF54-60B37EBFE800' or user_id = '1049C5F5-9E7A-A984-FF54-60B37EBFE800'";
$friends = Backendless::$Data->of("Friends")->find($query0)->getAsClass();

Same results…

BackendlessDataQuery retrieves only 10 objects by default. In order to retrieve all objects matching a query, you need either to set page size manually, like $query0->setPageSize(100);, or use nextPage method of BackendlessCollection, which will retrieve the next 10 objects of the collection.

Okay! Thanks for the info!

So if I do nextpage too early, I’ll loose bunch of 10 results?
Can I set this to unlimited to be sure to get all at once?


Initially you have access to 1-10 results, when you do nextPage - you have access to 11-20 results, and so on. So to some extent, yes, you loose the first 10 results if you failed to process them before.

There is no option to set an unlimited pageSize, but you may set some big value to it, which will be effectively the same.