<?php
$pdo = new pdo('sqlite::memory:', null, null, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
$pdo->exec('create table example( foo text, bar int )');
$prepared = $pdo->prepare('select foo from example');
$parameterized = $pdo->prepare('select foo from example where bar = ?');
echo $prepared->queryString, "\n", $parameterized->queryString;
$badSyntax = $pdo->prepare('select foo from example from example');
select foo from example
select foo from example where bar = ?
Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 1 near "from": syntax error in /in/WFtvg:9
Stack trace:
#0 /in/WFtvg(9): PDO->prepare('select foo from...')
#1 {main}
thrown in /in/WFtvg on line 9
Process exited with code 255.
Output for 5.6.0 - 5.6.40
select foo from example
select foo from example where bar = ?
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1 near "from": syntax error' in /in/WFtvg:9
Stack trace:
#0 /in/WFtvg(9): PDO->prepare('select foo from...')
#1 {main}
thrown in /in/WFtvg on line 9
Process exited with code 255.