CodeIgniter Forums
Automatic stripslashes() of everything retrieved from database? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Automatic stripslashes() of everything retrieved from database? (/thread-34314.html)



Automatic stripslashes() of everything retrieved from database? - El Forum - 09-25-2010

[eluser]Jakobud[/eluser]
When using the ActiveRecord database classes, the data (by default) is automatically escaped using the XSS-Clean stuff. So naturally there can end up being a lot of data in the database that is escaped with backslashes.

Is there anyway to automatically strip the slashes of all the data retrieved from the database in my models?

I can obviously just use stripslashes() on the data when I use/echo it in my views, but it would be nice not have have to stripslashes() for every single bit of data... I figured maybe there is an easy way for CI to do it for you when you are retrieving the data? Any clues?


Automatic stripslashes() of everything retrieved from database? - El Forum - 09-25-2010

[eluser]Developer13[/eluser]
A couple of things come to mind here... what version of PHP are you running? If magic_quotes_runtime is somehow being forced on, then you could end up with the slashes in your DB. The other thing that could cause them is the method in which you're inserting data into your database. I don't believe XSS filtering by itself is going to cause this. Could you post a quick snippet of your data insert methods?


Automatic stripslashes() of everything retrieved from database? - El Forum - 09-25-2010

[eluser]CroNiX[/eluser]
I've never had to strip slashes from data retrieved via active record...what are you doing to you data before inserting?


Automatic stripslashes() of everything retrieved from database? - El Forum - 09-25-2010

[eluser]Developer13[/eluser]
@CroNiX - What's the point of posting something that reiterates what I've already asked?


Automatic stripslashes() of everything retrieved from database? - El Forum - 09-26-2010

[eluser]Jakobud[/eluser]
I was mistaken. The test code that was written was not using Active Record and the slashes were being added manually. So feel free to ignore this thread. Thanks!


Automatic stripslashes() of everything retrieved from database? - El Forum - 09-26-2010

[eluser]CroNiX[/eluser]
@D13, they were posted at the same time...look at the date/time.


Automatic stripslashes() of everything retrieved from database? - El Forum - 09-26-2010

[eluser]Developer13[/eluser]
Hey you're right! Apparently I was being an ass Smile