config database.php file - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: config database.php file (/showthread.php?tid=5069) |
config database.php file - El Forum - 01-03-2008 [eluser]cinewbie81[/eluser] Hi guys, IN CI, we need to pre-define database setting in database config file before we can actually use that database. It's rather troublesome especially for those users without the programming background. Thus i was thinking to create a GUI and let the user to type in the database name. From user input, I will then append the content to the database config file automatically. Here's how the database config file looks like: Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); My problem now is how can I append the new content just right before the php closing tag '?>'. Any idea ? config database.php file - El Forum - 01-03-2008 [eluser]Chris Newton[/eluser] You could write this info to a database table. or You could write it to a text file and include it. or You could open this file, and overwrite it with the new data. config database.php file - El Forum - 01-03-2008 [eluser]cinewbie81[/eluser] Hi, i choose to open this file, and overwrite it with the new data. I found this on some other site: Code: $f="myfile.txt"; this fill append the new data into the 1st line and remove the last line of the file.. In my case i need to append the new data into the 2nd last line of the file (just right before php closing tag '?>' ... how can i do it ? config database.php file - El Forum - 01-04-2008 [eluser]ejangi[/eluser] Instead of trying to add it before the current ?>, why not just add a new PHP block: Code: $f="myfile.txt"; config database.php file - El Forum - 01-05-2008 [eluser]Grahack[/eluser] I think that you can forget this closing tag, it's even better without it: see Zend coding standards at B.2.1. |