Giter Club home page Giter Club logo

Comments (6)

solyoung avatar solyoung commented on July 19, 2024 1

Here's a suggestion that would allow query functionality to get through that function (it's how I have the code modified in the meantime):
private function _getJsonPath($path)
{
$url = $this->_baseURI;
$path = ltrim($path, '/');
$qaToken = (strpos($path, '?') == FALSE) ? '?' : '&';
$auth = ($this->_token == '') ? '' : $qaToken . 'auth=' . $this->_token;
$incJSON = (strpos($path, '.json') == FALSE) ? '.json' : '';
return $url . $path . $incJSON . $auth;
}

*note, if you use the above, you need to include .json in your original request. e.g. $firebaseLib->get('test.json?orderBy=email'); If you don't include .json, the above will still append .json at the end of that path.

from firebase-php.

askinner2004 avatar askinner2004 commented on July 19, 2024 1

I modified the firebaseLib.php file with the following lines to add some query functionality:
...
private $_options;
...
//This functions sets the options and ensures that the data is enclosed in QUOTATIONS
//Just before submitting the data, works really great.
public function setOptions($options = NULL)
{
if($options !== NULL)
{
foreach($options as $f => $v)
{
$new_options[$f] = '"' . $v . '"';
}
} else {
$new_options = $options;
}
$this->_options = $new_options;
}
...
// I modified this function to build the query string just before submitting
// and it converts %22 to QUOTATION marks before returning.
private function _getJsonPath($path)
{
$url = $this->_baseURI;
$path = ltrim($path, '/');
$auth = ($this->_token == '') ? '' : 'auth=' . $this->_token;
if($this->_options != NULL)
{
$data = http_build_query($this->_options);
$auth = "?". str_replace('%22','"',$data) . "&" . $auth;
} else {
$auth = "?" . $auth;
}
$new_url = $url . $path . '.json' . $auth;
return $new_url;

}

from firebase-php.

markdrake avatar markdrake commented on July 19, 2024

I'm having the same issue as solyoung. I wanted to use the query options but as you hard code the auth variable as the only query param available you make it impossible to use this without modification. I know it's a very simple wrapper but a more dynamic params approach would be ideal.

from firebase-php.

ktamas77 avatar ktamas77 commented on July 19, 2024

Thank you for your suggestion, this is a very important feature. I marked it as a todo.

from firebase-php.

reedgz avatar reedgz commented on July 19, 2024

I would love to see this feature as well. Then we can use shallow copy and other query options.
'https://samplechat.firebaseio-demo.com/.json?shallow=true'

from firebase-php.

ktamas77 avatar ktamas77 commented on July 19, 2024

Query parameters are supported in version v2.1.0

https://github.com/ktamas77/firebase-php/releases/tag/v2.1.0

from firebase-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.