Welcome Guest, Not a member yet? Register   Sign In
Storing $_GET parameters to DB for later use across multiple 'controllers/models'
#1

[eluser]Jaketoolson[/eluser]
As has been mentioned earlier, I'm porting an existing site over to CI. One of the most important 'features' the site has is the ability to save post parameters in the DB and then use said parameters to query the DB and either email the results, create a CSV file, create a XML file, and of course serve them to the browser.

The existing method would simple take the URI_PROTOCOL and save it as-is in the DB and then save the page from which these parameters came. For example, if the user were on the reports page, and set the report to display specific parameters using a form, the url would be:

'reports.php?hub_id=11&tod=1&time=month&month_in_detail=0&bulk=0';

If they wanted to save these this dynamic report based on the settings they selected, with the click of a button the following would be saved to the db:

"INSERT INTO table ('page', 'query_string') VALUES ('reports', 'hub_id=11&tod=1&time=month&month_in_detail=0&bulk=0')"

I'm brainstorming a better method/approach to this for CI and can't figure out what would be best. And to add to this brainstorming session, before the settings are saved the code also checks to see if the exact same settings for the same page don't already exist. Unfortunately, if the string were re-ordered such that it appeared like so:

bulk=0&hub_id=11&time=month&month_in_detail=0&tod=1

It would store this in the DB as a new value set when its the exact same as the example above only in a different order.

Again the reason the parameters are stored is to that with a CRON JOB or other method, the users settings for specific reports can be recreated and emailed to them daily, or CSV files can be delivered etc;
#2

[eluser]InsiteFX[/eluser]
Would the database helper help here?
Code:
$this->db->insert_string();
// and this one
$this->db->update_string();

Not sure if these would help you, but you can have a look at them.

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB