2017 © Pedro Peláez

library mongofunk

Extends Mongo classes to better support various formats



Extends Mongo classes to better support various formats

  • Monday, May 6, 2013
  • by jrschumacher
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown



Build Status, (*1)

Fixin' the funk out of Mongo classes., (*2)

Some of the Mongo classes act a little funky. This library intends to fix those., (*3)


Capitalization Funk

If you pass a capitalized string to MongoId it will store your string, (*4)

$id = new MongoId("00000000000000000000AAAA");


object (
  "$id" => "00000000000000000000AAAA"

Now what happens if print it? Funk., (*5)

print $id; // 00000000000000000000aaaa

And what about comparing? Funk., (*6)

$id == 00000000000000000000AAAA // FALSE


As soon as the string is passed we strtolower it. Defunked., (*7)

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., (*8)


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., (*9)


You can now pass DateTime objects to MongoDate., (*10)

$date = new DateTime();
$mdate = new MongoDate($date);
$date->getTimestamp() == $mdate->sec; // TRUE

You can also get a DateTime from MongoDate object, (*11)

$mdate->getDateTime(); // returns DateTime instance


From my expierience that is the main frustrations, but more can be added., (*12)

The Versions

06/05 2013


9999999-dev https://github.com/jrschumacher/mongofunk

Extends Mongo classes to better support various formats

  Sources   Download


by Ryan Schumacher