Skip to content

Commit 84e8f09

Browse files
Removed redundant if and use short array syntax (#571)
1 parent 74155fb commit 84e8f09

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

reference/pdo/prepared-statements.xml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,9 @@ $stmt->execute();
107107
<![CDATA[
108108
<?php
109109
$stmt = $dbh->prepare("SELECT * FROM REGISTRY where name = ?");
110-
if ($stmt->execute(array($_GET['name']))) {
111-
while ($row = $stmt->fetch()) {
112-
print_r($row);
113-
}
110+
$stmt->execute([$_GET['name']]);
111+
foreach ($stmt as $row) {
112+
print_r($row);
114113
}
115114
?>
116115
]]>
@@ -175,11 +174,11 @@ print "procedure returned $value\n";
175174
<![CDATA[
176175
<?php
177176
$stmt = $dbh->prepare("SELECT * FROM REGISTRY where name LIKE '%?%'");
178-
$stmt->execute(array($_GET['name']));
177+
$stmt->execute([$_GET['name']]);
179178
180179
// placeholder must be used in the place of the whole value
181180
$stmt = $dbh->prepare("SELECT * FROM REGISTRY where name LIKE ?");
182-
$stmt->execute(array("%$_GET[name]%"));
181+
$stmt->execute(["%$_GET[name]%"]);
183182
?>
184183
]]>
185184
</programlisting>

0 commit comments

Comments
 (0)