Welcome Guest, Not a member yet? Register   Sign In
changing some data form config folder by the controler
#1

[eluser]Niebieszki[/eluser]
Hello

I have a question, how to make such as installer to change the data value from database.php.

How to create a controller like 'installer' which change the data once and all other controller can use this data?

eg. Application on first run ask you which DB what to use and what data to connect witch.

In User Guide I've read how to change data for one controller, but my question is how to change to whole application?
#2

[eluser]Niebieszki[/eluser]
have anybody do this in your project?
#3

[eluser]Twisted1919[/eluser]
here is how i would do it:
1) having in mind that the tricky part is the database, i would chmod the database.php file to 0777 so that i can write in it while i am doing the "install"(of course after install, chmod 0755 back for security reasons).
2)Look in these forums for MY_Config, it will allow you to save your website config to database rather than file.
3.a) Having the MY_Config set and correct permissions on database.php, when running the installer, i would save the database connection details and other website general settings to session/or just keep them in $_POST.
If the database settings are correct, then i would write the database.php file (file_put_contents() ?) with the data from session/$_POST then i would import all other session variables related to the website into database.
3.b) In the way i write database.php file, i can do it for config.php too, this means i won't need MY_Config extension.
4) Done, remove install or cancel the controller.(you can do a trick here, check if some table exists, if it does, than stop the install process, because the app is already installed, else continue with install process)

It's easy though, hope you get the idea .
#4

[eluser]InsiteFX[/eluser]
Download PyroCMS and look at it's installer code.
It will show you how to everything you want.

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB