<?php
class DATABASE_CONFIG {
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'hostname',
'login' => 'username',
'password' => 'password',
'database' => 'database_name',
'prefix' => '',
//'encoding' => 'utf8',
);
public $test = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'hostname',
'login' => 'username',
'password' => 'password',
'database' => 'database_name',
'prefix' => '',
//'encoding' => 'utf8',
);
}
There are some default value in login,password and database. How can i write a script to edit the login,password and database ?
php file contains your example text:
this only changes the blocks after your $default block. and, only default value will be changed. e.g. in your $test,
'database' => 'cake_test_db'the value is not the default ‘xxx’, so it would not be changed.if you like you can put new value in variable, and passing to awk with -v.
edit
if you want to change all values, (including $default block), it would be easier, check the lines below: (same as above, only defalut values (root, xxx,xxx) would be changed.
edit2
this works for your new example in question.