• 11

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

i am currently working on a search function in my app. this gets a reference of my firebase database snapshot. im using the firebaseDatabase package for this.

currently im using this to search my database


the searchQuery variable is the the used string to search the database. this returns the list of products which the titles are equal to searchQuery.

searchQuery = 'hello';
title1 = 'hello';
title2 = 'hello there';

for now, only

searchQuery == title1;
searchQuery != title2;

but i also want this to be returned

searchQuery == title2;

is this possible in the way im using this for now?

You are looking for a contains query, but Firebase doesn't provide that. You can refine your actual query by looking for values that are equalTo or endAt or startAt (these methods are available to you as well). Making three requests is going to be costly, though.

If your database is not large and your data is not sensitive, I suggest fetching the whole data and making a client-side filter as shown here.

  • 1
Reply Report
      • 2
    • i saw that a query like .equalsTo(query + " f8ff" will return everything what comes after the query text. so query "hello"+" f8ff" will also return "hello there". so i thought " f8ff" + "there"+ " f8ff" would also return "hello there" but this is not the case. i dont know why such a basic query is not implemented :(