parse.com-php-library is open source and available on GitHub.
Today we needed a function to filter our records on a specific date in the database.
The most obvious way to solve it was to combine a call to whereGreaterThanOrEqualTo() with a call to whereLessThanOrEqualTo(), but it will not work since it will handle it as an OR query.
The solution was to add a new function to parseQuery.php:
public function whereBetweenOrEqualTo($key, $startValue, $endValue){ if(isset($key) && isset($startValue) && isset($endValue)){ $this->_query[$key] = array( '$gte' => $startValue, '$lte' => $endValue ); } else{ $this->throwError('the $key, $startValue and $endValue parameters must be set when setting a "where" query method'); } }
We could just have added it to our own parseQuery.php and continued to work, but since it is open source and on GitHub it is very easy to contribute to the original project.
- Fork the project you would like to contribute to - Go to the project at the GitHub web page and click the Fork button.
- Clone the code to your computer. There is an application for GitHub that will handle repositories on GitHub for you which will make cloning, committing and other tasks very easy.
- Make changes to the code.
- Commit your changes to your local repository. Use the GitHub application to make it easier.
- Push your changes to the remote server. It is called Sync in the GitHub application.
- Go to your project and click Pull requests and then New pull request.
- Follow the instructions to create a pull request for your changes and write an informative comment: "Fixes #117. Query for between or equal to start and end value."
Hash + issue number will automatically be linked to the issue number. - If the owner of the original repository likes the changes he/she will add them to the repository.
Inga kommentarer:
Skicka en kommentar