1

Could anyone please tell me how MongoDB can be used with YII?

How can we create controller and model functions using Gii if the database used is MongoDB?

Ben
  • 54,723
  • 49
  • 178
  • 224
user1708645
  • 21
  • 1
  • 5

2 Answers2

2

The way of creating controllers is same as usual but you have to use an extension to talk to mongoDB from Yii ,

You need to use direct Mongo suite of yii . It is an extension which has a collection of components for the mongoDB .

Ben
  • 54,723
  • 49
  • 178
  • 224
Aravind.HU
  • 9,194
  • 5
  • 38
  • 50
  • Does the `directmongosuite` work with `gii` .. have you used it? – Stennie Oct 01 '12 at 23:55
  • 1
    If you are using gii , then use yiimongodbsuite dont go for directmongosuite [yiimongosuite](http://www.yiiframework.com/extension/yiimongodbsuite/#hh5) – Aravind.HU Oct 02 '12 at 05:29
  • 1
    So the original question was about using Gii (though there was an incorrect edit today where someone thought Gii was typoed Yii) ;-) – Stennie Oct 02 '12 at 05:41
2

I've used YiiMongoDBSuite (YMDS), which has some very rough support for Gii. You can generate starter classes, but given that MongoDB does not have a fixed schema you will need to edit the model to make them useful. There is an odd kludge that lets you generate MongoDB models from a SQL table, but this seems more effort than it's worth.

YMDS' EMongoDocument class extends the standard Yii CModel class, so this is a useful base if you want to build apps with CRUDS.

The unfortunate caveat is that YMDS is no longer maintained by the original author, and there are a few community forks to chose between.

Stennie
  • 63,885
  • 14
  • 149
  • 175