Welcome Guest, Not a member yet? Register   Sign In
prepare data for display and for database
#1

[eluser]Jagar[/eluser]
I've been looking for a safe way to store data in the database and then display it on the browser. I've looked at form_prep, but it does not do what I want, so I started my own function helper i.e. prep_for_database, prep_for_display,.

This new functions of mine they work great on strings and array, now I'm trying to apply that to $this->db->row(), and since it's not an array, but an object I can't do anything.

I would appreciate if somebody could help me out preparing the row for display especially.

Thanks
#2

[eluser]Jagar[/eluser]
getting result_array() instead of row solves the problem, but what is the advantage of row() over result_array()?
#3

[eluser]TheFuzzy0ne[/eluser]
result_array() returns an array of results, row returns an object representing the first row of the result set.

Generally speaking, for consistency you should use row_array() and result_array(), or row() and result().

Use row() or row_array() when you're expecting a single result, and result() or result_array() when you're expecting more than a single row. Generally, if you're expecting a single result row, you will add a LIMIT clause to your query, so the query only returns a single row.
#4

[eluser]Dam1an[/eluser]
Just to add to what fuzzy said about expecting single rows, you can expect a single row (and don't need the limit) if the lookup is on a unique field, such as an auto incrementing id, email, username etc
#5

[eluser]Jagar[/eluser]
Thanks TheFuzzy0ne and Dam1an, I'm using row_array() which works great, and now can pass the whole data for preparing for display.

Thanks




Theme © iAndrew 2016 - Forum software by © MyBB