reference/pdo/pdo/construct.xml
7dd805d34addc6e98afaa0b3851c8656afbec9b6
7dd805d34addc6e98afaa0b3851c8656afbec9b6
...
...
@@ -1,4 +1,4 @@
1
-
<?xml version="1.0" encoding="UTF-8"?>
1
+
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
3
<refentry xml:id="pdo.construct" xmlns="http://docbook.org/ns/docbook">
4
4
<refnamediv>
...
...
@@ -9,12 +9,12 @@
9
9
</refnamediv>
10
10
<refsect1 role="description">
11
11
&reftitle.description;
12
-
<constructorsynopsis>
13
-
<methodname>PDO::__construct</methodname>
12
+
<constructorsynopsis role="PDO">
13
+
<modifier>public</modifier> <methodname>PDO::__construct</methodname>
14
14
<methodparam><type>string</type><parameter>dsn</parameter></methodparam>
15
-
<methodparam choice="opt"><type>string</type><parameter>username</parameter></methodparam>
16
-
<methodparam choice="opt"><type>string</type><parameter>password</parameter></methodparam>
17
-
<methodparam choice="opt"><type>array</type><parameter>driver_options</parameter></methodparam>
15
+
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>username</parameter><initializer>&null;</initializer></methodparam>
16
+
<methodparam choice="opt"><modifier role="attribute">#[\SensitiveParameter]</modifier><type class="union"><type>string</type><type>null</type></type><parameter>password</parameter><initializer>&null;</initializer></methodparam>
17
+
<methodparam choice="opt"><type class="union"><type>array</type><type>null</type></type><parameter>options</parameter><initializer>&null;</initializer></methodparam>
18
18
</constructorsynopsis>
19
19
<para>
20
20
Creates a PDO instance to represent a connection to the requested
...
...
@@ -25,7 +25,8 @@
25
25
&reftitle.parameters;
26
26
<para>
27
27
<variablelist>
28
-
<varlistentry><term>dsn</term>
28
+
<varlistentry>
29
+
<term><parameter>dsn</parameter></term>
29
30
<listitem>
30
31
<para>
31
32
The Data Source Name, or DSN, contains the information required to
...
...
@@ -80,7 +81,8 @@
80
81
</para>
81
82
</listitem>
82
83
</varlistentry>
83
-
<varlistentry><term>username</term>
84
+
<varlistentry>
85
+
<term><parameter>username</parameter></term>
84
86
<listitem>
85
87
<para>
86
88
The user name for the DSN string. This parameter is optional for
...
...
@@ -88,7 +90,8 @@
88
90
</para>
89
91
</listitem>
90
92
</varlistentry>
91
-
<varlistentry><term>password</term>
93
+
<varlistentry>
94
+
<term><parameter>password</parameter></term>
92
95
<listitem>
93
96
<para>
94
97
The password for the DSN string. This parameter is optional for
...
...
@@ -96,7 +99,8 @@
96
99
</para>
97
100
</listitem>
98
101
</varlistentry>
99
-
<varlistentry><term>driver_options</term>
102
+
<varlistentry>
103
+
<term><parameter>options</parameter></term>
100
104
<listitem>
101
105
<para>
102
106
A key=>value array of driver-specific connection options.
...
...
@@ -107,18 +111,12 @@
107
111
</para>
108
112
</refsect1>
109
113
110
-
<refsect1 role="returnvalues">
111
-
&reftitle.returnvalues;
112
-
<para>
113
-
Returns a PDO object on success.
114
-
</para>
115
-
</refsect1>
116
-
117
114
<refsect1 role="errors">
118
115
&reftitle.errors;
119
116
<para>
120
-
<function>PDO::__construct</function> throws a <classname>PDOException</classname> if the attempt
121
-
to connect to the requested database fails.
117
+
A <classname>PDOException</classname> is thrown if the attempt
118
+
to connect to the requested database fails,
119
+
regardless of which <constant>PDO::ATTR_ERRMODE</constant> is currently set.
122
120
</para>
123
121
</refsect1>
124
122
...
...
@@ -129,16 +127,12 @@
129
127
<programlisting role="php">
130
128
<![CDATA[
131
129
<?php
132
-
/* Connect to an ODBC database using driver invocation */
130
+
133
131
$dsn = 'mysql:dbname=testdb;host=127.0.0.1';
134
132
$user = 'dbuser';
135
133
$password = 'dbpass';
136
134
137
-
try {
138
-
$dbh = new PDO($dsn, $user, $password);
139
-
} catch (PDOException $e) {
140
-
echo 'Connection failed: ' . $e->getMessage();
141
-
}
135
+
$dbh = new PDO($dsn, $user, $password);
142
136
143
137
?>
144
138
]]>
...
...
@@ -164,16 +158,12 @@ odbc:DSN=SAMPLE;UID=john;PWD=mypass
164
158
<programlisting role="php">
165
159
<![CDATA[
166
160
<?php
167
-
/* Connect to an ODBC database using driver invocation */
161
+
168
162
$dsn = 'uri:file:///usr/local/dbconnect';
169
163
$user = '';
170
164
$password = '';
171
165
172
-
try {
173
-
$dbh = new PDO($dsn, $user, $password);
174
-
} catch (PDOException $e) {
175
-
echo 'Connection failed: ' . $e->getMessage();
176
-
}
166
+
$dbh = new PDO($dsn, $user, $password);
177
167
178
168
?>
179
169
]]>
...
...
@@ -192,16 +182,12 @@ pdo.dsn.mydb="mysql:dbname=testdb;host=localhost"
192
182
<programlisting role="php">
193
183
<![CDATA[
194
184
<?php
195
-
/* Connect to an ODBC database using an alias */
185
+
196
186
$dsn = 'mydb';
197
187
$user = '';
198
188
$password = '';
199
189
200
-
try {
201
-
$dbh = new PDO($dsn, $user, $password);
202
-
} catch (PDOException $e) {
203
-
echo 'Connection failed: ' . $e->getMessage();
204
-
}
190
+
$dbh = new PDO($dsn, $user, $password);
205
191
206
192
?>
207
193
]]>
...
...
@@ -210,7 +196,6 @@ try {
210
196
</para>
211
197
</refsect1>
212
198
</refentry>
213
-
214
199
<!-- Keep this comment at the end of the file
215
200
Local variables:
216
201
mode: sgml
217
202