Skip to content

Commit

Permalink
Update pdo_db::escape() to accept an array
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtorrent committed Nov 13, 2011
1 parent 1981d1f commit 1a72bac
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions pdo/db.php
Expand Up @@ -110,11 +110,22 @@ function createDBObject(){
* similarly, using mysql_escape_string() (which you would think would be logical) screws things up to.
* basically does not honour line terminators.
*
* @param $string string the variable to be escaped
* @param string|array $data to escape
* @return string escaped variable
*/
function escape($string) {
return addslashes($string);
function escape($data) {
if (is_array($data)) {
foreach ($data as $k => $v) {
if (is_array($v))
$data[$k] = $this->escape($v);
else
$data[$k] = addslashes($v);
}
} else {
$data = addslashes($data);
}

return $data;
}

/**
Expand Down

0 comments on commit 1a72bac

Please sign in to comment.