Answer the question
In order to leave comments, you need to log in
How to assign a value to a global variable from a database?
Good afternoon, in YII there is a params file, how to make it so that, for example, the email field is taken from the database, from a specific column?
<?php
return [
'adminEmail' => '[email protected]',
];
Answer the question
In order to leave comments, you need to log in
#Получить из базы
Yii::$app->params['adminEmail'] = "полученный email";
$config = [
#другие конфиги
'bootstrap' => ['log' /*По умолчанию в Yii подключен */, function () {
$adminEmail = (new Query())->select(["email"])->from("config")->where([/*условие*/])->scalar();
Yii::$app->params['adminEmail'] = $adminEmail;
}],
#другие конфиги
];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question