0

I want to search users from friebase just like we use LIKE in mysql to get related results. if someone enter asi the returning result should be all users which should contain asi in their firstname or lastname.

Is there any way to do it? i read all the documentation by firebase but could not find solution for this.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

1 Answers1

0

You can fetch data something like by passing full name or Email.

$user = $firebase->getReference("users/{$uid}")
           ->orderByChild("email")
           ->equalTo("mail@mail.com")
           ->getSnapshot();

or you can use startAt so you can search with startAt keyword.

->orderByChild("email")
->startAt("mail@mail.com")

You can use similar functionality first() like laravel query

->limittoFirst(1);

You can follow this query :

->orderByChild("email")
->startAt("asi")
->endAt("[a-zA-Z0-9]*")
Ashish
  • 6,791
  • 3
  • 26
  • 48