reference/pdo/pdo/prepare.xml
082ddc19f53e6e254010de1a1fbbe485ff744ec1
...
...
@@ -9,7 +9,7 @@
9
9
</refnamediv>
10
10
<refsect1 role="description">
11
11
&reftitle.description;
12
-
<methodsynopsis>
12
+
<methodsynopsis role="PDO">
13
13
<modifier>public</modifier> <type class="union"><type>PDOStatement</type><type>false</type></type><methodname>PDO::prepare</methodname>
14
14
<methodparam><type>string</type><parameter>query</parameter></methodparam>
15
15
<methodparam choice="opt"><type>array</type><parameter>options</parameter><initializer>[]</initializer></methodparam>
...
...
@@ -120,6 +120,11 @@
120
120
</note>
121
121
</refsect1>
122
122

123
+
<refsect1 role="errors">
124
+
&reftitle.errors;
125
+
&pdo.errors;
126
+
</refsect1>
127
+

123
128
<refsect1 role="examples">
124
129
&reftitle.examples;
125
130
<para>
...
...
@@ -131,11 +136,11 @@
131
136
$sql = 'SELECT name, colour, calories
132
137
FROM fruit
133
138
WHERE calories < :calories AND colour = :colour';
134
-
$sth = $dbh->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
135
-
$sth->execute(array('calories' => 150, 'colour' => 'red'));
139
+
$sth = $dbh->prepare($sql, [PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY]);
140
+
$sth->execute(['calories' => 150, 'colour' => 'red']);
136
141
$red = $sth->fetchAll();
137
142
/* Array keys can be prefixed with colons ":" too (optional) */
138
-
$sth->execute(array(':calories' => 175, ':colour' => 'yellow'));
143
+
$sth->execute([':calories' => 175, ':colour' => 'yellow']);
139
144
$yellow = $sth->fetchAll();
140
145
?>
141
146
]]>
...
...
@@ -150,9 +155,9 @@ $yellow = $sth->fetchAll();
150
155
$sth = $dbh->prepare('SELECT name, colour, calories
151
156
FROM fruit
152
157
WHERE calories < ? AND colour = ?');
153
-
$sth->execute(array(150, 'red'));
158
+
$sth->execute([150, 'red']);
154
159
$red = $sth->fetchAll();
155
-
$sth->execute(array(175, 'yellow'));
160
+
$sth->execute([175, 'yellow']);
156
161
$yellow = $sth->fetchAll();
157
162
?>
158
163
]]>
159
164