installing YiiMongoDbSuite, help please

Hello everyone,

I’m pretty new to Yii framework. Here what I’ve done for installing YiiMongoDbSuite:

  • Adding zip export to private/extensions with renaming the file YiiMongoDbSuite.

  • Changing config/main.php like said in readme -> Comment out (or delete) the current ‘db’ array for your database in the components section, and add the following to the file:

‘import’ => array(

  ...


  'ext.YiiMongoDbSuite.*',


),





'components' => array(


  ...


  'mongodb' => array(


    'class'            => 'EMongoDB',


    'connectionString' => 'mongodb://localhost',


    'dbName'           => 'myDatabaseName',


    'fsyncFlag'        => true,


    'safeFlag'         => true,


    'useCursor'        => false


  ),


),

When I login gii and try to create model, giving that error:

CDbConnection.connectionString cannot be empty.

Any advice, tips please?

PS: Sorry for bad English. :confused:

I don’t think you can use YiiMongoDbSuite with the Gii module.

YiiMongoDbSuite supports gii and it’s great, a quick way to migrate from mysql or others to mongoDB.

See: YiiMongoDbSuite Manual

i’ve already made that proces but still giving the same error and dont allow me to create a new model. i’ve changed my framework to fatfree framework just becouse of mongodb, but i dont want another framework. does anybody experienced on yiimongodbsuite, please help me, waiting please:S

Did you do this? ->


'modules'=>array(

    // ...

 

    'gii'=>array(

        'class'=>'system.gii.GiiModule',

        'password'=>'yours_password_to_gii',

        // add additional generator path

        'generatorPaths'=>array(

            'ext.YiiMongoDbSuite.gii'

        ),

    ),

	// ...

),  

Otherwise, you need to tell us more of what you actually did - so that we can tell you what you did not… ;)

study !!

I’m new and just tried MongoDBSuite. I’ve done everything suggested on the thread and believe the model generator on the latest stable version is dead. I’m not sure if it ever worked, but its dead now, or I’m doing something wrong.

I think the problem is in the init function of MongoModelCode.php. Notice how db is referenced instead of mongodb.


public function init()

	{

		if(Yii::app()->db===null)

			throw new CHttpException(500,'An active "db" connection is required to run this generator.');

		$this->tablePrefix=Yii::app()->db->tablePrefix;

		parent::init();

	}



Searching google groups for gii will show what happens if mongodb is changed to db in the main.php file (where connection strings are stored). I would post the link, but no links in first post… In a nut shell, it complains about EMongoDB doesn’t have a tablePrefix property, which it doesn’t. EMongoDB doesn’t seem to exist in the project at all except in the main.php declaration.

Please let me know what I’m supposed to do to get this to work…

1. The EMongoDB.php exists in the latest release ‘ymds-1.4-pr1.zip’.

In config/main.php you should have added:




'import' => array(

      ...

      'ext.YiiMongoDbSuite.*',

    ),



So EMongoDB should be known by Yii.

See the Setup section of yiimongodbsuite.

2. gii from yiimongodbsuite

The code and the ‘function init()’ is ok.

With the help of this gii extension you can migrate tables from a relational db (mysql …) to the mongoDB.

So you have two connection component in the config/main.php.

  • ‘db’ for the connection to mysql, postgresql…

  • ‘mongodb’ for the connection to the mongoDB

Don’t change these componentnames.

The codegenerator will read the fieldnames / types from the table you have specified and will generate a model and a controller with all views for CRUD operations for usage with the yiimongodbsuite (means the fields as public properties in the model, rules, actionCreate …).

I’ts a great tool to migrate existing tables from relational databases to the mongoDB and it works.

1.4 is not a stable version, so I didn’t use it.

The db connection components were commented out, as per the instructions in the setup section, since I didn’t need them (new project, not migration).

If you read the OP, you will see that following the instructions will cause the error: "CDbConnection.connectionString cannot be empty".

It looks like the reason is because the db connection component, but the instructions tell you to comment out or delete them.

I’m not saying that the only possibility is that mongosuite gii is broke, but since I followed the instructions to the t, I’m not sure what configuration error I could have made…

OK, for anyone else who has this problem, you DO need a ‘db’ component.

From the requirements, it seems the gii mongomodel generator is made to ONLY convert db tables to mongo collections.

You cannot use it to create a new model from scratch.

After I added the db component, and ran the model generator, it worked.

However, it will fail if you don’t have the table created in mysql first (only tested on mysql).

I created the table in mysql and then ran the generator again and success!

One more thing! Running the CRUD generator throws a "failed to open stream: no such file or directory windows" in mongo.php.

That’s because I didn’t install the mongo driver on my webserver, but on my database server.

Installing the windows driver from GIT link in mongodb didn’t make a difference, but installing the version from the Installation Docs(php.net) VC6 ThreadSafe did the trick.

Hi every one,

Following all of yours instruction, I am able to create model ,crud using mongoCRUD Generator and mongoModel Generator and able to insert a data using create action but when i try to go to admin its giving me following error.Is there any one who can help?

Fatal error: Call to a member function getDbCriteria() on a non-object in D:\xampp\htdocs\test_mongo\protected\extensions\YiiMongoDbSuite\EMongoDocumentDataProvider.php on line 73

Thanks