Encourage using prepared statements

This commit is contained in:
Nat Zimmermann
2019-02-27 19:52:08 +00:00
committed by Fabien Potencier
parent ea371bee81
commit 97d9dc0404
+2 -2
View File
@@ -409,8 +409,8 @@ First, let's create a temporary in-memory SQLite3 database to work with::
{% block content %}Hello {{ name }}{% endblock %}
';
$now = time();
$dbh->exec("INSERT INTO templates (name, source, last_modified) VALUES ('base.twig', '$base', $now)");
$dbh->exec("INSERT INTO templates (name, source, last_modified) VALUES ('index.twig', '$index', $now)");
$dbh->prepare('INSERT INTO templates (name, source, last_modified) VALUES (?, ?, ?)')->execute(['base.twig', $base, $now]);
$dbh->prepare('INSERT INTO templates (name, source, last_modified) VALUES (?, ?, ?)')->execute(['index.twig', $index, $now]);
We have created a simple ``templates`` table that hosts two templates:
``base.twig`` and ``index.twig``.