G
G
Grigory Kalyashov2015-10-20 20:31:26
Yii
Grigory Kalyashov, 2015-10-20 20:31:26

How to connect MongoDB to yii?

Started learning Yii 1.1. There was a need to connect the mongodb database using the mongodbsuite extension. I read off-documentation . Set up
main.php :

[php]
    'import' => array(
      ...
      'ext.YiiMongoDbSuite.*',
    ),
    'components' => array(
      ...
      'mongodb' => array(
        'class'            => 'EMongoDB',
        'connectionString' => 'mongodb://localhost',
        'dbName'           => 'testdb',
        'fsyncFlag'        => true,
        'safeFlag'         => true,
        'useCursor'        => false
      ),
    ),

But when entering gii -> Model generator, an error occurs: On this line: Yes, and the code given in the documentation does not work. The database itself is located in the data folder of the framework, in the same place as other databases. MongoDB version is 3 with something. What could be the problem? Install lower version of mongo? How to make friends yii and mongodb? And how to work with it after connection?
CDbConnection.connectionString cannot be empty.
if(Yii::app()->{$this->connectionId}===null)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Puma Thailand, 2015-10-20
@opium

In the latest version, the protocol has changed in mongodb and apparently in the outdated ivaywai no one has
updated the old monga. What does the database in the date folder mean in your monga itself is running?

A
Alexander, 2015-10-20
@Sassoft

Get Yii2 right away

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question