Yii With Mongo Db

Hi ,

 Could anyone please tell me how mongodb can be used with yii.How can we create controller and model function using gii if the database used is mongodb.Iam not able to create it Please advice.

There exists no gii for the mongodb and IMHO there will never exist one…

One mongo-collection can contain different data and (array-)structures, no need for homogenous records.

A gii never can analyse the structure of a collection to generate controllers/views because there is nothing defined in the collection (Fieldnames, Datatypes, Datasize …).

You can save whatever (arrays/binaries) you want into a collection and thats one of the reasons I like the mongoDB :wink:

  • yiimongodbsuite has a gii feature to create yiimongodbsuite-models from a relational db.

But it only makes sense as the first step if you want to migrate from MySQL or others.

  • If you want to work with models you can take a look at the code of the mongocms.

It’s old, but it’s an example how to use the yiimongodbsuite. Maybe you find some ideas there.

  • Take a look at the methods/features of the directmongosuite if you want to work with the mongodb with no ‘model overhead’.

My recommendation:

Use yiimongodbsuite and directmongosuite together.