Even after a lot of reading, I didn't get one thing. Is PDO escaping data IF I am NOT using bindValue or bindParam ? Maybe I didn't understand what "prepare" exactly does. I know it's storing a procedure as an object. I know it's performance benefits (even used it with transactions) but escaping is the only thing I didn't understand
Suppose this:
$db = new PDO('mysql:host=' . $config['db']['host'] . ';dbname=' . $config['db']['dbname'], $config['db']['username'], $config['db']['password'], $config['db']['options']);
$query = $db->prepare("INSERT INTO table (col1, col2) VALUES (:col1, :col2)");
$result = $query->execute(array('col1' => $val_col1, 'col2' => $val_col2));
Where/when is the actual escape being done ? While preparing or while binding a param/value ? What if I'm skipping this:
$query->bindParam(":col1", $val_col1);
$query->bindParam(":col2", $val_col2);
Note that I have PDO::ATTR_EMULATE_PREPARES set to false (it's set in $config array)
Using PHP 5.4.13 and MySQL 5.1.67