• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
prepare data for display and for database

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.


getting result_array() instead of row solves the problem, but what is the advantage of row() over result_array()?

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.

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

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.