M
M
marsep2014-11-03 15:49:56
Yii
marsep, 2014-11-03 15:49:56

Is it possible to change config data in Yii 1 not in the file itself?

Yii has a config folder with the main configuration file, where the script returns an array with configuration data. Is it possible to change these configuration data later from other classes, for example, to change the data for the database? If so, how can you access this data using Yii?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ilya Plotnikov, 2014-11-06
@marsep

I suspect that you need to use multiple databases. To do this, simply add a component with the CDBConnection class.
I see no point in editing the config after it has been loaded, because it is not reread after launch.

M
Max, 2014-11-03
@AloneCoder

Why would you?

A
Alexander, 2014-11-03
@misantron

To override config elements in the module, there are methods of the CModule class - setComponent or setComponents.
To use different configurations, for example, in dev and prod environments, you can create a separate file in the config folder for the local environment, for example local.php, where you can override the data for connecting to the database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question