Welcome Guest, Not a member yet? Register   Sign In
From and Database Value Comparisons
#1

[eluser]sweetD[/eluser]
Does CodeIgniter already have a form database value comparison?

What I'm trying to accomplish is the following when a form opened to update information, I want it to pull from the database (currently using mongo) and populate the input value, if not then populate from the post if any errors, and if not then NULL value when the form is opened.

The second thing I would like to accomplish, is if the data already exists to not update it, that would be a form rule correct? I have an idea of how to accomplish this but was looking to see what would be the best practice to accomplish this.
#2

[eluser]CroNiX[/eluser]
This is easy using the form_helper with form_validation and also set_value('fieldname', $default'), where $default will be your original data from the database which would show up on page load. If the user submits the form and there is a validation error, it will repopulate the form with whatever they entered. No errors, update.

If you try to "update" a database row, but no info actually changes, MySQL will ignore the update. It only actually performs an update if data actually changes. This is much more efficient than running a query to get the old data, checking it against the new data to see if anything changed and if it did, then update.




Theme © iAndrew 2016 - Forum software by © MyBB