reference/pdo/pdo/construct.xml
a1f229dc3ec7d7932797e156bd8f9fbf40904b25
...
...
@@ -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"><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=&gt;value array of driver-specific connection options.
...
...
@@ -107,18 +111,11 @@
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
+
<methodname>PDO::__construct</methodname> throws a <classname>PDOException</classname> if the attempt
118
+
to connect to the requested database fails, regardless of which <constant>PDO::ATTR_ERRMODE</constant> is currently set.
122
119
</para>
123
120
</refsect1>
124
121

...
...
@@ -129,16 +126,12 @@
129
126
<programlisting role="php">
130
127
<![CDATA[
131
128
<?php
132
-
/* Connect to an ODBC database using driver invocation */
129
+

133
130
$dsn = 'mysql:dbname=testdb;host=127.0.0.1';
134
131
$user = 'dbuser';
135
132
$password = 'dbpass';
136
133

137
-
try {
138
-
$dbh = new PDO($dsn, $user, $password);
139
-
} catch (PDOException $e) {
140
-
echo 'Connection failed: ' . $e->getMessage();
141
-
}
134
+
$dbh = new PDO($dsn, $user, $password);
142
135

143
136
?>
144
137
]]>
...
...
@@ -164,16 +157,12 @@ odbc:DSN=SAMPLE;UID=john;PWD=mypass
164
157
<programlisting role="php">
165
158
<![CDATA[
166
159
<?php
167
-
/* Connect to an ODBC database using driver invocation */
160
+

168
161
$dsn = 'uri:file:///usr/local/dbconnect';
169
162
$user = '';
170
163
$password = '';
171
164

172
-
try {
173
-
$dbh = new PDO($dsn, $user, $password);
174
-
} catch (PDOException $e) {
175
-
echo 'Connection failed: ' . $e->getMessage();
176
-
}
165
+
$dbh = new PDO($dsn, $user, $password);
177
166

178
167
?>
179
168
]]>
...
...
@@ -192,16 +181,12 @@ pdo.dsn.mydb="mysql:dbname=testdb;host=localhost"
192
181
<programlisting role="php">
193
182
<![CDATA[
194
183
<?php
195
-
/* Connect to an ODBC database using an alias */
184
+

196
185
$dsn = 'mydb';
197
186
$user = '';
198
187
$password = '';
199
188

200
-
try {
201
-
$dbh = new PDO($dsn, $user, $password);
202
-
} catch (PDOException $e) {
203
-
echo 'Connection failed: ' . $e->getMessage();
204
-
}
189
+
$dbh = new PDO($dsn, $user, $password);
205
190

206
191
?>
207
192
]]>
...
...
@@ -210,7 +195,6 @@ try {
210
195
</para>
211
196
</refsect1>
212
197
</refentry>
213
-

214
198
<!-- Keep this comment at the end of the file
215
199
Local variables:
216
200
mode: sgml
217
201