Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jrschumacher/mongofunk
Fix the funk out of PECL Mongo
https://github.com/jrschumacher/mongofunk
Last synced: about 3 hours ago
JSON representation
Fix the funk out of PECL Mongo
- Host: GitHub
- URL: https://github.com/jrschumacher/mongofunk
- Owner: jrschumacher
- License: mit
- Created: 2013-05-06T15:03:45.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-05-06T15:48:23.000Z (over 11 years ago)
- Last Synced: 2024-10-08T22:20:58.537Z (about 1 month ago)
- Language: PHP
- Size: 109 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
MongoFunk
=========[![Build Status](https://secure.travis-ci.org/jrschumacher/mongofunk.png?branch=master)](http://travis-ci.org/jrschumacher/mongofunk)
> Fixin' the funk out of Mongo classes.
Some of the Mongo classes act a little funky. This library intends to fix those.
## MongoId
### Capitalization Funk
If you pass a capitalized string to MongoId it will store your string
```
$id = new MongoId("00000000000000000000AAAA");var_dump($id);
/*
object (
"$id" => "00000000000000000000AAAA"
)
*/
```Now what happens if print it? Funk.
```
print $id; // 00000000000000000000aaaa
```And what about comparing? Funk.
```
$id == 00000000000000000000AAAA // FALSE
```#### Defunked
As soon as the string is passed we `strtolower` it. Defunked._Why don't you just output the passed format?_ Well that has some issue with consistency in the database.
This way I am hoping most of the bases are covered, but will need to do some further tests.## MongoDate
### DateTime Funk
Per the documentation you need to pass an integer which represents a Unix timestamp or microtimestamp.
This is understandable except DateTime is much more powerful and from the OO perspective a much better
solution than timestamps.#### Defunked
You can now pass DateTime objects to MongoDate.
```
$date = new DateTime();
$mdate = new MongoDate($date);
$date->getTimestamp() == $mdate->sec; // TRUE
```You can also get a DateTime from MongoDate object
```
$mdate->getDateTime(); // returns DateTime instance
```## More
From my expierience that is the main frustrations, but more can be added.