Welcome Guest, Not a member yet? Register   Sign In
Form data to database
#1

[eluser]0x0b4dc0d3[/eluser]
After processing form data with the form validation class, and it is necessary to get that data into the database, what is the preferred way to get all of the post data into an object or an array?
#2

[eluser]überfuzz[/eluser]
[quote author="0x0b4dc0d3" date="1258670519"]After processing form data with the form validation class, and it is necessary to get that data into the database using the active record method class, what is the preferred to get all of the post data into an object or an array, so that it can be easily inserted / updated?[/quote]
Chose the path of your liking... I guess it's 50/50 for me, I like both ways.
#3

[eluser]0x0b4dc0d3[/eluser]
[quote author="überfuzz" date="1258671015"][quote author="0x0b4dc0d3" date="1258670519"]After processing form data with the form validation class, and it is necessary to get that data into the database using the active record method class, what is the preferred to get all of the post data into an object or an array, so that it can be easily inserted / updated?[/quote]
Chose the path of your liking... I guess it's 50/50 for me, I like both ways.[/quote]

Thanks for your feedback, but I was not asking about which datatype to put the post variables into, specifically I was asking what is best practice for taking all of the data and putting it into an array or object. Sorry for the miscommunication.
#4

[eluser]überfuzz[/eluser]
[quote author="0x0b4dc0d3" date="1258675323"][quote author="überfuzz" date="1258671015"][quote author="0x0b4dc0d3" date="1258670519"]After processing form data with the form validation class, and it is necessary to get that data into the database using the active record method class, what is the preferred to get all of the post data into an object or an array, so that it can be easily inserted / updated?[/quote]
Chose the path of your liking... I guess it's 50/50 for me, I like both ways.[/quote]

Thanks for your feedback, but I was not asking about which datatype to put the post variables into, specifically I was asking what is best practice for taking all of the data and putting it into an array or object. Sorry for the miscommunication.[/quote]
What are you going to jam into you database then..?
#5

[eluser]merrick.christensen[/eluser]
Woah, just did my own topic and accidentally submitted to this. Sorry!
#6

[eluser]Colin Williams[/eluser]
Quote:When accessing the post array at this point has CodeIgniter already prepped and validated it?

All prepping/cleaning is done directly to the $_POST array.

Quote:What is to stop some one from posting directly to your Model? Skipping validation and prepping all together?

There is no URI -> Model mapping conventions in CI.

And to the OPs question, I just toss the $_POST array at my models. No sense in building a new special array for it. My model sanitizes everything it .gets, so there's no concern there. You just need to be smart about building your models.
#7

[eluser]0x0b4dc0d3[/eluser]
[quote author="Colin Williams" date="1258678176"]
Quote:When accessing the post array at this point has CodeIgniter already prepped and validated it?

All prepping/cleaning is done directly to the $_POST array.

Quote:What is to stop some one from posting directly to your Model? Skipping validation and prepping all together?

There is no URI -> Model mapping conventions in CI.

And to the OPs question, I just toss the $_POST array at my models. No sense in building a new special array for it. My model sanitizes everything it .gets, so there's no concern there. You just need to be smart about building your models.[/quote]

Thanks this was exactly what I was looking for.




Theme © iAndrew 2016 - Forum software by © MyBB