0

I'm starting with firebase to use with Flutter. For the backend, I wanted to use PHP with the https://firebase-php.readthedocs.io/ SDK... Found the samples on basic queries .... get user by ID for example:

public function get(int $usuarioID = NULL) {
    if (empty($usuarioID) || !isset($usuarioID)) { return false; }
    if ($this->database->getReference($this->dbname)->getSnapshot()->hasChild($usuarioID))
    {
        return $this->database->getReference($this->dbname)->getChild($usuarioID)->getValue();
    }
    else
    {
        return false;
    }
}

But how can I query by email+password to see if the login is ok? does the getChild allow mixed/multiple parameters?

Thanks! Diego

Edit: similar question here: Query based on multiple where clauses in Firebase. It still doesnt cover 100% but seems to me like the path to follow. Thanks for the answer/comments

diegoarg79
  • 111
  • 1
  • 6
  • Firebase Realtime Database queries can only order/filter on a single property. In many cases it is possible to combine the values you want to filter on into a single (synthetic) property. For example, you could have a property `"email_password": "value of email_value of password"` and order/filter on *that*. For a longer example of this and other approaches, see my answer here: https://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase – Frank van Puffelen Jul 06 '20 at 22:46
  • Thanks, yes, similar to the suggestion on the related question...but it sounds stange..add combined properties for each posible search combinations sounds a little crazy.. for this login case might be ok...but if you waht to add a search that looks at mutiple fileds? I think I'm looking at this wrong.... maybe my head is tied to a different database query logic.. – diegoarg79 Jul 06 '20 at 22:59
  • 1
    If often helps to not think of Firebase as a traditional database as much as a tree of data that is automatically synchronized between clients. If you need elaborate querying, you might be better served by another tool. If you need near realtime synchronization, use Firebase. If you're new to this domain, I always recommend reading [NoSQL data modeling](https://highlyscalable.wordpress.com/2012/03/01/nosql-data-modeling-techniques/) and watching [Firebase for SQL developers](https://www.youtube.com/playlist?list=PLl-K7zZEsYLlP-k-RKFa7RyNPa9_wCH2s). – Frank van Puffelen Jul 06 '20 at 23:36
  • Thanks! Yes... I'm too used to traditional databases..will take a read to that... I think I need that firebase "style"... but might combine with a traditional database for security logic accounts – diegoarg79 Jul 07 '20 at 02:05

0 Answers0