File: preparation.xml

package info (click to toggle)
php-doc 20081024-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 57,752 kB
  • ctags: 3,858
  • sloc: xml: 686,554; php: 19,446; perl: 610; cpp: 500; makefile: 336; sh: 114; awk: 28
file content (191 lines) | stat: -rw-r--r-- 6,890 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<sect1 xml:id="internals2.pdo.preparation" xmlns="http://docbook.org/ns/docbook">
 <title>Preparation and Housekeeping</title>
 <sect2 xml:id="internals2.pdo.preparation.layout">
  <title>Source directory layout</title>

  <para>
   The source directory for a typical PDO driver is laid out as follows, where
   <literal>SKEL</literal> represents a shortened form of the name of the
   database that the driver is going to connect to.  Even though SKEL is
   presented here in uppercase (for clarity), the convention is to use
   lowercase characters.
  </para>
  <screen>
<![CDATA[
pdo_SKEL/          
  config.m4                  # unix build script
  config.w32                 # win32 build script
  CREDITS
  package.xml                # meta information about the package
  pdo_SKEL.c                 # standard PHP extension glue
  php_pdo_SKEL.h
  php_pdo_SKEL_int.h         # driver private header
  SKEL_dbh.c                 # contains the implementation of the PDO driver interface
  SKEL_stmt.c                # contains the implementation of the PDO statement interface
  tests/
]]>
  </screen>
  <para>The contents of these files are defined later in this document.</para>
 </sect2>
 <sect2 xml:id="internals2.pdo.preparation.create-skel">
  <title>Creating a skeleton</title>

  <para>
   The easiest way to get started is to use the <command>ext_skel</command>
   shell script found in the PHP build tree in the <filename>ext</filename>
   directory. This will build a skeleton directory containing a lot of the
   files listed above. It can be build by executing the following command from
   within the <filename>ext</filename> directory:
  </para>
  <screen>
<![CDATA[
./ext_skel --extname=pdo_SKEL
]]>
  </screen>
  <para>
   This will generate a directory called pdo_SKEL containing the
   skeleton files that you can then modify. This directory should then be
   moved out of the php extension directory . PDO is a PECL extension and
   should not be included in the standard extension directory. As long as you
   have PHP and PDO installed, you should be able to build from any directory.
  </para>
 </sect2>
 <sect2 xml:id="internals2.pdo.preparation.std-includes">
  <title>Standard Includes</title>
  <sect3 xml:id="internals2.pdo.preparation.std-includes.build-specific">
   <title>Build Specific Headers</title>
   <para>
    The header file config.h is generated by the configure process for the
    platform for the which the driver is being built. If this header is
    present, the HAVE_CONFIG_H compiler variable is set. This variable should
    be tested for and if set, the file config.h should be included in the
    compilation unit.
   </para>
  </sect3>
  <sect3 xml:id="internals2.pdo.preparation.std-includes.php">
   <title>PHP Headers</title>
   <para>
    The following standard public php headers should be included in each
    source module:
   </para>
   <orderedlist>
    <listitem>
     <para>php.h</para>
    </listitem>
    <listitem>
     <para>php_ini.h</para>
    </listitem>
    <listitem>
     <para>ext/standard/info.h</para>
    </listitem>
   </orderedlist>
  </sect3>
  <sect3 xml:id="internals2.pdo.preparation.std-includes.pdo">
   <title>PDO Interface Headers</title>
   <para>
    The following standard public PDO header files are also included in each
    source module:
   </para>
   <variablelist>
    <varlistentry>
     <term>pdo/php_pdo.h</term>
     <listitem>
      <para>
       This header file contains definitions of the initialization and shutdown
       functions in the main driver as well as definitions of global PDO
       variables.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term>pdo/php_pdo_driver.h</term>
     <listitem>
      <para>
       This header contains the types and API contracts that are used to write
       a PDO driver. It also contains method signature for calling back into
       the PDO layer and registering/unregistering your driver with 
       PDO. Most importantly, this header file contains the type
       definitions for PDO database handles and statements. The two main
       structures a driver has to deal with, pdo_dbh_t and pdo_stmt_t, are
       described in more detail in Appendix A and B.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </sect3>
  <sect3 xml:id="internals2.pdo.preparation.std-headers.driver-spec">
   <title>Driver Specific Headers</title>
   <para>
    The typical PDO driver has two header files that are specific to the
    database implementation. This does not preclude the use of more depending
    on the implementation. The following two headers are, by convention,
    standard:
   </para>
   <variablelist>
    <varlistentry>
     <term>php_pdo_SKEL.h</term>
     <listitem>
      <para>
       This header file is virtually an exact duplicate in functionality
       and content of the previously defined pdo/php_pdo.h that has been
       specifically tailored for your database. If your driver requires
       the use of global variables they should be defined using the
       ZEND_BEGIN_MODULE_GLOBALS and ZEND_END_MODULE_GLOBALS macros.
       Macros are then used to access these variables. This macro is
       usually named PDO_SKEL_G(v) where v is global variable to be
       accessed. Consult the Zend programmer documentation for more
       information.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term>php_pdo_SKEL_int.h</term>
     <listitem>
      <para>
       This header file typically contains type definitions and function
       declarations specific to the driver implementation. It also should
       contain the db specific definitions of a pdo_SKEL_handle and
       pdo_SKEL_stmt structures. These are the names of the private
       data structures that are then referenced by the driver_data members
       of the handle and statement structures.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </sect3>
  <sect3 xml:id="internals2.pdo.preparation.std-headers.optional">
   <title>Optional Headers</title>
   <para>
    Depending on the implementation details for a particular driver it may be
    necessary to include the following header:
   </para>
   <programlisting role="c">
<![CDATA[
#include <zend_exceptions.h>
]]>
   </programlisting>
  </sect3>
 </sect2>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->