thatguy
thatguy

Reputation: 837

Returning MYSQL DB results with array_map

I'm currently using a custom PHP framework. It has a Class designed to handle interaction with the MYSQL database.

The select function, takes the table and a query, generates rows via mysqli_fetch_array($result, MYSQL_ASSOC) and either returns a regular array (each row is one element in the array) or FALSE if there are no results returned.

I'm thinking about adding the following statement to automatically always remove escaping slashes from the results

$data[] = array_map('stripslashes',$row );

As this class is used all over the application for returning anything from the database, would this be a sensible idea, versus always remembering to output data with stripslashes whenever it's from user or third party input?

Upvotes: 1

Views: 640

Answers (1)

Amit Shah
Amit Shah

Reputation: 1380

It would be good to add config switch to class, and when fetching data from it

you should pass the switch if want to stripslashes the data otherwise not,

Thanks Amit

Upvotes: 1

Related Questions