1

I was looking into MongoDB module, but found it very verbose and overly complicated to perform simple DB operations and this module seems to be tightly integrated with Drupal entities.

Is there any other Drupal-PDO wrapper for Mongodb that is easy, secure (NO SQL injection free) for simple DB operations in Drupal?

Thanks for your time.

  • 1
    What are you trying to accomplish with MongoDB? In Drupal, it isn't meant to replace the database, but rather to supplement it for offloading some tables that don't really need SQL-style relations. – mpdonadio Aug 8 '12 at 14:06
  • I have csv files that contain external data(coming from somewhere else), I need to push that into both Mongodb and My-sql, to keep them in sync. The problem is not that, its impossible, but rather the size of csv is too big to keep check on malicious content. Currently I am using php's internal wrapper for mongodb, but its not safe and I want something more secure. Thanks – Eugene Gerome Aug 8 '12 at 14:11
  • 1
    chx posted a MongoDB DBTNG driver some time back (code files here). The comments suggest he has success using it to install Drupal and run a few core tests, so it might be worth a look – Clive Aug 8 '12 at 14:31
  • 1
    Thanks Clive, DBTNG is , I think, what I am looking for. However I also found another wrapper called Ming. I will look into both solutions and see which one works best for me. Thanks. – Eugene Gerome Aug 8 '12 at 15:46
  • I think ming will probably work out better than the DBTNG version, see @kiamlaluno's comment – Clive Aug 8 '12 at 16:54
1

As far as I can see, there isn't any PDO wrapper for MongoDB, and there isn't any code that allows to use MongoDB as database for Drupal, simply for the fact Drupal expects to use an SQL database engine, while MongoDB is not an SQL database. You cannot generally convert a static query into code that uses MongoDB.

The Mongodb module allows you to use MongoDB in those cases where Drupal is not expecting to get data from a database, although the default implementation uses database table. That is what happens for the cache, entity fields, and Drupal queue, for which a module can define a new PHP class to implement a different mechanism to store data.

Notice that the Mongodb module is not tightly integrated with Drupal entities, as it doesn't use any Drupal entity to work. It eventually allows you to store field data in Mongodb, but that is an additional module you can eventually use. If you are not interested to store field data in MongoDB, the main module (mongodb.module) still works, and can be used from the other sub-modules.

  • 1
    I was surprised but there is one out there – Clive Aug 8 '12 at 14:37
  • 1
    I guess it is not able to convert all the SQL queries, as its code contains the following line: echo 'Unsupported query: '. preg_replace('/\s+/', ' ', $query) ."\n";. – kiamlaluno Aug 8 '12 at 15:16
  • Ah I didn't see that ;) I guess that error would happen for joins/aggregations etc – Clive Aug 8 '12 at 15:22
1

First, NOSQL injection, as such doesn't exist. Second, the MongoDB project allows you to plug in higher level systems where such pluggability is available. Third, the mongodb_dbtng project is a proof of concept but it's bereft of problems and it won't go anywhere. Fourth, Drupal 8 will support MongoDB much better but still not in a way that you can write PDO-like code against MongoDB.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.