Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Support for MongoDB?
  • Hi, I've just started testing with FuelPHP and so far I'm really liking it. One thing I'm really missing though is proper support for MongoDB. I've found that Fuel includes a MongoDB class but it looks like it's pretty much a standalone class that you include in your code, rather than one that utilizes the framework itself (primarily the models). What are my options here? I don't wan to have to manually establish a connection every time I need to talk to Mongo, and I'd really like to make use of my models to ease the process. Also, there doesn't seem to be any documentation on the MongoDB class, or am I missing something? Thank you.
  • Brad Proctor wrote on Wednesday 28th of March 2012:
    MongoRegex is a part of the PHP Mongo extension, not part of FuelPHP, and it's only use is on this line:
    $this->wheres[$field] = new \MongoRegex($regex);
    

    which is looking for it in the global namespace. Are you possibly using an older version of FuelPHP?
    Hi Brad, You're right - after some research I figured it out, on my code it was missing the \ before MongoRegex on the line below:
    $this->wheres[$field] = new MongoRegex($regex);
    

    I added the namespace identifier and it worked out fine. Thanks a lot.
    $this->wheres[$field] = new \MongoRegex($regex);
    

  • Thanks for the info. Looking forward to native support of MongoDB in FuelPHP. For now I modified MangoDB (https://github.com/Wouterrr/MangoDB) to work with FuelPHP. Seeing as Fuel is incredibly similar to Kohana it wasn't that hard.
  • What does MangoDB do that our current MongoDB class doesn't do?
  • From what I can tell, the difference is that Mango supports configs and models. See: https://github.com/Wouterrr/MangoDemo/blob/master/classes/model/comment.php Of course I'd prefer to use Fuel's native MongoDB library for this, but the fact that it lacks proper integration with the framework as well as documentation or code samples makes it difficult.
  • MangoDB for FuelPHP forked here if anyones interested: https://github.com/Naatan/MangoDB-for-Fuel Obviously only a temporary solution until FuelPHP provides proper native support.
  • I'm trying to use the Mongo->Like method and it is not working properly. It is missing classes. I got this error ErrorException [ Error ]: Class 'Fuel\Core\MongoRegex' not found
    Also in the Mongo_Db class there was an error on the line 520. $this->where_init($field); ->> this method doesnt exist $this->_where_init($field); --> this seems to be correct
  • MongoDB is indeed a separate class. I've added the missing docs to the issue list. For models (I assume you mean ORM) to support different query languages, we need to rework our current query builder (which originates in Kohana, and only understands ANSI SQL). There is a separate feature branch for this work, where I'm currently busy with Transact-SQL support. Due to the feature freeze it will not be implemented in v1.0.
  • MongoRegex is a part of the PHP Mongo extension, not part of FuelPHP, and it's only use is on this line:
    $this->wheres[$field] = new \MongoRegex($regex);
    

    which is looking for it in the global namespace. Are you possibly using an older version of FuelPHP?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion