No-escape underscores in MySQL table/column identifiers

Underscore _ doesn't require escaping in table/column identifiers
since it isn't treated as a wildcard in that context
This commit is contained in:
Michael Berkowski
2014-12-29 21:37:49 -06:00
parent 906a915843
commit 76352ae677

View File

@@ -14,13 +14,13 @@ MySQL or SQLite:
<?php
// PDO + MySQL
$pdo = new PDO('mysql:host=example.com;dbname=database', 'user', 'password');
$statement = $pdo->query("SELECT some\_field FROM some\_table");
$statement = $pdo->query("SELECT some_field FROM some_table");
$row = $statement->fetch(PDO::FETCH_ASSOC);
echo htmlentities($row['some_field']);
// PDO + SQLite
$pdo = new PDO('sqlite:/path/db/foo.sqlite');
$statement = $pdo->query("SELECT some\_field FROM some\_table");
$statement = $pdo->query("SELECT some_field FROM some_table");
$row = $statement->fetch(PDO::FETCH_ASSOC);
echo htmlentities($row['some_field']);
{% endhighlight %}