dongliao3742 2019-03-21 13:50
浏览 78

与PHP的Firebase Filteringdata

I already tested this Firebase Filtering data with PHP but im getting this error and i dont have any clue how to debug this

Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: GET https://table.firebaseio.com/tbl_admin?orderBy=%22username%22&equalTo=%22admin%22&limitToFirst=1 resulted in a 400 Bad Request response: { "error" : "Index not defined, add \".indexOn\": \"username\", for path \"/tbl_admin\", to the rules" } in D:\Xampp\htdocs\firebase\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php:113 Stack trace: #0 D:\Xampp\htdocs\firebase\vendor\guzzlehttp\guzzle\src\Middleware.php(66): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 D:\Xampp\htdocs\firebase\vendor\guzzlehttp\promises\src\Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response))

2 D:\Xampp\htdocs\firebase\vendor\guzzlehttp\promises\src\Promise.php(156):

GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #3 D:\Xampp\htdocs\firebase\vendor\guzzlehttp\promises\src\TaskQueue.php(47): GuzzleHttp\Prom in D:\Xampp\htdocs\firebase\vendor\kreait\firebase-php\src\Firebase\Exception\QueryException.php on line 28

how will i filter this on firebase as i have queried it on mysql like this:

SELECT * FROM tbl_admin WHERE username = 'admin'

A table structure on firebase

  • 写回答

1条回答 默认 最新

  • dongyi1441 2019-03-22 08:22
    关注

    If you read the error message, you'll find that it says:

    Index not defined, add ".indexOn": "username", for path "/tbl_admin", to the rules

    You can add those rules by navigating to the Database Rules section in the Firebase Web Console of your project (https://console.firebase.google.com/project/_/database/_/rules should™ bring you there) and adding the index so that your rules look something like this:

    {
        "rules": {
            ".read": false,
            ".write": false,
            "tbl_admin": {
              ".indexOn": ["username"]
            }
        }
    }
    

    The important part is the tbl_admin field, don't just copy and paste the snippet if you already have other settings in your rules ^^.

    enter image description here

    评论

报告相同问题?

悬赏问题

  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 matlab求解平差
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办