![]() |
[SOLVED] Updating Database - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: [SOLVED] Updating Database (/showthread.php?tid=60853) |
[SOLVED] Updating Database - El Forum - 07-13-2014 [eluser]riwakawd[/eluser] I am making a form which lets me select what theme I would like to use and it should update the database and then update my config file. In my config file I have made $config['config_template'] = $template; Config File Setting.php Code: <?php I am trying to get it so when I choose what theme I am after it will update the database with value i.e name of theme. And make it so the config item stays on the theme selected from database. How do I make it work like that? I can see the themes fine in select form. Controller Code: <?php Model Code: <?php View Code: <form method="post" acti echo base_url('setting');?>"> [SOLVED] Updating Database - El Forum - 07-14-2014 [eluser]Tim Brownlaw[/eluser] Where would you prefer to save your current theme setting? The Database OR the Config file.. Having both is silly because, in your script where does it decide where it should go and look? You can of course update the config setting (Not the config file setting ) from the Database each time a page is loaded. In your database you would have an options or settings table which you can read in each time and store in memory and write a method to retrieve those kinds of thing from it... That way it's only one DB Select instead of performing a DB Select each time you need it throughout the current script. That's beneficial for things you need to know more than once during the running of the script. You could have it so if there's been no setting or a valid setting in the options table, to go and read the config setting as the default OR better is to set the actual default theme in the options table on installation (preferred method). There's a bunch of ways to do things. But I see no point in setting a value in the DB AND rewriting your config file for a theme setting... Unless you have some reason I cannot see! Check your model - I see one too many } (on the end) Check your view - The first line is wrong! Typo on action and incomplete <?php .... ?> [SOLVED] Updating Database - El Forum - 07-14-2014 [eluser]riwakawd[/eluser] [quote author="Tim Brownlaw" date="1405328252"]Where would you prefer to save your current theme setting? The Database OR the Config file.. Having both is silly because, in your script where does it decide where it should go and look? You can of course update the config setting (Not the config file setting ) from the Database each time a page is loaded. In your database you would have an options or settings table which you can read in each time and store in memory and write a method to retrieve those kinds of thing from it... That way it's only one DB Select instead of performing a DB Select each time you need it throughout the current script. That's beneficial for things you need to know more than once during the running of the script. You could have it so if there's been no setting or a valid setting in the options table, to go and read the config setting as the default OR better is to set the actual default theme in the options table on installation (preferred method). There's a bunch of ways to do things. But I see no point in setting a value in the DB AND rewriting your config file for a theme setting... Unless you have some reason I cannot see! Check your model - I see one too many } (on the end) Check your view - The first line is wrong! Typo on action and incomplete <?php .... ?> [/quote] The typo on view in form is to do with in here won't let me put full action. I would like to be able to submit form then it updates the row in database and then sets the config item. Below here is how I do the front controller to load view. I can do it manually buy that I mean change name on my config file OK just would like to do it via form. Code: <?php [SOLVED] Updating Database - El Forum - 07-14-2014 [eluser]riwakawd[/eluser] [quote author="Tim Brownlaw" date="1405328252"]Where would you prefer to save your current theme setting? The Database OR the Config file.. Having both is silly because, in your script where does it decide where it should go and look? You can of course update the config setting (Not the config file setting ) from the Database each time a page is loaded. In your database you would have an options or settings table which you can read in each time and store in memory and write a method to retrieve those kinds of thing from it... That way it's only one DB Select instead of performing a DB Select each time you need it throughout the current script. That's beneficial for things you need to know more than once during the running of the script. You could have it so if there's been no setting or a valid setting in the options table, to go and read the config setting as the default OR better is to set the actual default theme in the options table on installation (preferred method). There's a bunch of ways to do things. But I see no point in setting a value in the DB AND rewriting your config file for a theme setting... Unless you have some reason I cannot see! Check your model - I see one too many } (on the end) Check your view - The first line is wrong! Typo on action and incomplete <?php .... ?> [/quote] I have almost got it working now can update database model just need now to make my $store_info['config_template'] to work with the config item. And also just have to work out how to make it row id to stop changing but just to be fixed. Code: <?php Model edit part Code: public function editSetting($group, $data, $store_id = 0) { |