ktamas77 / firebase-php

Firebase PHP Client
791 stars 215 forks source link

Cannot filter using equalTo/endAt/startAt with strings #64

Open Mogball opened 7 years ago

Mogball commented 7 years ago

Trying to do $database->ref('some/path')->orderByChild('childname').equalTo('stringvalue')->...

Will throw an error: "Constraint index field must be a JSON primitive".

So it seems strings don't work, but performing the same query in, say, javascript Firebase, is allowed with strings.

mastef commented 5 years ago

@Mogball See https://stackoverflow.com/a/41991196/10728554 or https://github.com/ktamas77/firebase-php/issues/58 about adding quotes around your strings.

Also the updated documentation has a case for this https://github.com/ktamas77/firebase-php#supported-commands.

forcequit commented 3 years ago

Adding to @masref

The key value must also be json encoded:

$key =json_encode("206"); $value = $firebase->get($path, array('orderBy' => '"url"', 'equalTo' => $key));