I test my Codeigniter site on the localhost then update it on a server. Many adjustment problems in switching between them. Are there.
So I want to configure it only by a constant: Then my database connection and password will be replaced by the location of my server (localhost or myhost) Accordingly configured. The only problem is that the database.php first runs the [Updated] application / config / autoload.php: Application / Library / mysettings.php: application / config / database.php You set the example To make the connection active, the group is only a group by default ('Default' group). * / $ Active_group = "Development"; $ Db ['development'] ['hostname'] = "localhost"; $ Db ['Evolution'] ['Username'] = "Us"; $ Db ['development'] ['password'] = ""; $ Db ['Evolution'] ['Database'] = "DB1"; MYCUSTOM_SERVER_LOCATION
mysettings library, even in a config file instead of a library the settings have the same results.
... $ autoload ['Library'] = array ('mysettings', 'database', 'session'); ...
& lt ;? Php if (! Defined ('BASEPATH')) Exit ('no permission to access any direct script'); Define ("MYCUSTOM_SERVER_LOCATION", "localhost"); Class mysettings {/////////////////////////////////////////////// /// // Options: Localhost // option: 000webhost // $ config ["mycustom_server"] = "localhost"; }
if (MYCUSTOM_SERVER_LOCATION == "localhost") {$ db ['default'] ['hostname'] = 'Localhost'; $ Db ['default'] ['username'] = '...'; $ Db ['default'] ['password'] = '...'; $ Db ['default'] ['database'] = '...'; } And if (MYCUSTOM_SERVER_LOCATION == "myserver") {$ db ['default'] ['hostname'] = '...'; $ Db ['default'] ['username'] = '...'; $ Db ['default'] ['password'] = '...'; $ Db ['default'] ['database'] = '...'; } Else {echo "unknown server."; Output Result:
encountered a PHP error Severity: Notification Message: Undefined Continued Use of MYCUSTOM_SERVER_LOCATION - Assumed ' MYCUSTOM_SERVER_LOCATION 'file name: config / database.php Line number: 51 was encountered a PHP error Seriousness: Notification Message: Undetermined Use of MYCUSTOM_SERVER_LOCATION -' MYCUSTOM_SERVER_LOCATION 'file named: config / database.php Line number: 58 Unknown server
$ activ_group variable
/ * $ activ_group variable which can be used in the application / config / database.php
No comments:
Post a Comment