我需要在 symfony 2.0 中更改特定登录的数据库名称(参数 .ini 文件)。所以我在会话中尝试了。但它不起作用。是否可以将会话值放入参数中。ini 文件?
我的代码:(参数 .ini 文件)
<?php
session_start();
$dbnamenew='';
if($_SESSION['test_db']!=""){
$dbnamenew=$_SESSION['test_db'];
}
else {
$dbnamenew ='test';
}
?>
; These parameters can be imported into other config files
; by enclosing the key with % (like %database_user%)
; Comments start with ';', as in php.ini
[parameters]
database_driver="pdo_mysql"
database_host="localhost"
database_port="22"
database_name="<?php echo dbnamenew;?>"
database_user="user"
database_password="pass"
mailer_transport="smtp"
mailer_host="localhost"
mailer_user=""
mailer_password=""
locale="en"
secret="b538e3680321a85b2e39a3d1772e0b711ff9371c"