|
53 | 53 | </para></listitem>
|
54 | 54 | <listitem><para>
|
55 | 55 | <literal>PDO::FETCH_CLASS</literal>: returns a new instance of the
|
56 |
| - requested class, mapping the columns of the result set to named |
57 |
| - properties in the class, and calling the constructor afterwards, unless |
58 |
| - <literal>PDO::FETCH_PROPS_LATE</literal> is also given. |
59 |
| - If <parameter>mode</parameter> |
60 |
| - includes PDO::FETCH_CLASSTYPE (e.g. <literal>PDO::FETCH_CLASS | |
61 |
| - PDO::FETCH_CLASSTYPE</literal>) then the name of the class is |
62 |
| - determined from a value of the first column. |
| 56 | + requested class. The object is initialized by mapping the columns of |
| 57 | + the result set to properties in the class. This occurs before the |
| 58 | + constructor is called, allowing properties to be populated regardless |
| 59 | + of their visibility or whether they are marked as <literal>readonly</literal>. |
| 60 | + If a property does not exist in the class, the magic <link linkend="object.set">__set()</link> |
| 61 | + method will be invoked if it exists; otherwise, a dynamic public |
| 62 | + property will be created. However, when <constant>PDO::FETCH_PROPS_LATE</constant> |
| 63 | + is also given, the constructor is called <emphasis>before</emphasis> |
| 64 | + the properties are populated. If <parameter>mode</parameter> includes |
| 65 | + <constant>PDO::FETCH_CLASSTYPE</constant> (e.g. |
| 66 | + <literal>PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE</literal>), the name |
| 67 | + of the class is determined from the value of the first column. |
63 | 68 | </para></listitem>
|
64 | 69 | <listitem><para>
|
65 | 70 | <literal>PDO::FETCH_INTO</literal>: updates an existing instance
|
@@ -266,11 +271,11 @@ Reading backwards:
|
266 | 271 |
|
267 | 272 | <example><title>Construction order</title>
|
268 | 273 | <simpara>
|
269 |
| - When objects are fetched via <literal>PDO::FETCH_CLASS</literal> the object |
| 274 | + When objects are fetched via <constant>PDO::FETCH_CLASS</constant>, the object |
270 | 275 | properties are assigned first, and then the constructor of the class is
|
271 |
| - invoked. If <literal>PDO::FETCH_PROPS_LATE</literal> is also given, this |
272 |
| - order is reversed, i.e. first the constructor is called, and afterwards the |
273 |
| - properties are assigned. |
| 276 | + invoked. However, when <constant>PDO::FETCH_PROPS_LATE</constant> is also given, |
| 277 | + this order is reversed, i.e. first the constructor is called, and |
| 278 | + afterwards the properties are assigned. |
274 | 279 | </simpara>
|
275 | 280 | <programlisting role="php">
|
276 | 281 | <![CDATA[
|
|
0 commit comments