Jump to content

real escape for pdo

- - - - -

  • Please log in to reply
1 reply to this topic

#1
lol33d

lol33d

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
hi guys

i want escape string for query

how to this?

in mysql is mysql_real_escape_string

what is this in PDO?

thank you

#2
Vaielab

Vaielab

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 547 posts
You can either either quote your data
$dbh->quote($string)
when $dbh is your instance of pdo
Or you can prepare your sql
$sth = $dbh->prepare('select * from user where id=:id');

$sth->execute(array(':id' => $id));
This is one way to prepare your sql, in pdo you can prepare it in many way
Here are one of the best tutorial for pdo that I read over the years: PHP Tutorials Examples Introduction to PHP PDO




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users